View Single Post
  #2  
Old 05-04-2009, 05:50 PM
welcomewiki welcomewiki is offline
Member
 
Join Date: Dec 2008
Location: India
Posts: 80,567
Display the Result in an HTML Table

The following example selects the same data as the example above, but will display the data in an HTML table:




$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");

echo "
<
tr>


"; while($row = mysql_fetch_array($result))
{
echo "";
echo "";
echo "";
echo "";
}
echo "
Firstname Lastname
" . $row['FirstName'] . "" . $row['LastName'] . "
"; mysql_close($con);
?>



The output of the code above will be:




Firstname Lastname Glenn Quagmire Peter Griffin
Reply With Quote