mysql results to a html table (mysql_fetch_array)
Posted: Mon Jul 31, 2006 9:28 am
feyd | Please use
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi
I’m new to php, I’m just trying to get a result from a mysql query into a html table
When I run this script it doesn’t show up a result, not even an error just a blank page, can some one let me know where I’m going wrong?
Thanks
ClintCode: Select all
<?PHP
//connect to the mysql database
$connection=mysql_connect("localhost","computer_test","test1");
mysql_select_db("computer_price",$connection);
$query="SELECT p.PartNumber, p.Description, (p.IncTax*1.3) AS Price FROM `price list` p";
$data_resource=mysql_query($query,$connection);
//Defining HTML table
$table="<table cellspacing=0 cellpadding=0 width=400>";
while ($row = mysql_fetch_array($data_resource)) {
$table.="<tr>";
$table.="<td>".$row['p.PartNumber']."</td>";
$table.="<td>".$row['p.Descripton']."</td>";
$table.="</tr>";
}
//Closing HTML table
$table.="</table>";
//Displying table and closing mysql database if not need
echo $table;
mysql_close();
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]