Associate
- Joined
- 11 Oct 2008
- Posts
- 268
I'm fairly new to php/mysql and I've been following the w3 tutorials.
i am using this code to connect to my database:
Is there anyway to echo the results without having to use this whole chunk of code every time?. I tried the following with no luck.
Does anyone know what I'm doing wrong?
i am using this code to connect to my database:
PHP:
<?php
$con = mysql_connect("localhost","peter","abc123");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("my_db", $con);
$result = mysql_query("SELECT * FROM Persons");
while($row = mysql_fetch_array($result))
{
echo $row['FirstName'] . " " . $row['LastName'];
echo "<br />";
}
mysql_close($con);
?>
Is there anyway to echo the results without having to use this whole chunk of code every time?. I tried the following with no luck.
PHP:
<?php
echo .$row['FirstName'];
?>
Does anyone know what I'm doing wrong?