The syntax for inserting values into tables,
INSERT INTO
table_name (`col1`, `col2`, `col3`,.....)
VALUES ('val1', 'val2', 'val3',.....);
<?php
$con = mysql_connect('localhost', 'root','');
mysql_select_db('dbname', $con) or die(mysql_error());
$query = "INSERT INTO table_name (`sno`, `name`, `marks`, `rank`,`post_of_date`) VALUES ('3', 'PHP Developer', '521', '36',now())";
$ok = mysql_query($query);
if($ok)
echo "Inserted successfully";
else
echo "Data's are not inserted in to table";
?>
INSERT INTO
table_name (`col1`, `col2`, `col3`,.....)
VALUES ('val1', 'val2', 'val3',.....);
<?php
$con = mysql_connect('localhost', 'root','');
mysql_select_db('dbname', $con) or die(mysql_error());
$query = "INSERT INTO table_name (`sno`, `name`, `marks`, `rank`,`post_of_date`) VALUES ('3', 'PHP Developer', '521', '36',now())";
$ok = mysql_query($query);
if($ok)
echo "Inserted successfully";
else
echo "Data's are not inserted in to table";
?>
sno | name | marks | rank | post_of_date |
---|---|---|---|---|
1 | Ram | 407 | 3 | 09-04-2001 |
2 | krishnan | 397 | 3 | 09-04-2001 |
3 | PHP Developer | 521 | 36 | 27-03-2012 |
0 comments:
Post a Comment