Thursday, April 16, 2009

Database insert 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","");
mysql_select_db("phpDB",$con);
$nameVal="DVD";
$priceVal="25";
$imagepathVal="c:/image.jpg";
$updateDayVal="2008-09-10";
$categoryIdVal="156";
$query='insert into product(name,price,imagepath,updateDay,category_id)
values("'.$nameVal.'",'.$priceVal.',"'.
$imagepathVal.'","'.$updateDayVal.'",'
.$categoryIdVal.")";
mysql_query($query);
$query="commit";
mysql_query($query);
mysql_close($con);
?>

No comments:

Post a Comment