Thursday, April 16, 2009

Database select operation using PHP

TABLE STRUCTURE

Product

id integer primary key auto_increment,name varchar(50),price decimal(10,2),category_id integer,imagepath varchar(100),updateDay date

PHP CODE

<?php
$con=mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
else
{

mysql_select_db("phpDB",$con);
$query="select * from product";
$result=mysql_query($query,$con);
while($row=mysql_fetch_array($result))
{
echo $row["id"].$row["name"].$row["price"].$row["imagepath"].$row["updateDay"].$row["category_id"];
}
}
?>

No comments:

Post a Comment