i am using this code to add values to database
<?php
$debdes = $_POST['debdes'];
$debamt = $_POST['debamt'];
$crdes = $_POST['crdes'];
$cramt = $_POST['cramt'];
$date = $_POST['date'];
include_once ("db.php");
$ucbook = "INSERT INTO cbook(debdes,debamt,crdes,cramt,date) VALUES ('$debdes','$debamt','$crdes','$cramt','$date');";
if (mysql_query($ucbook))
echo "One Record Updated Successfully with the following det开发者_开发知识库ails <br/>";
else
echo mysql_error();
?>
now i want that when query pass this show me that which values are added like this
"Following record is updated successfully
debamt = 1000 debdes = test
end "
if the query does not fails, you can just show your values:
.
.
.
if (mysql_query($ucbook)){
echo "One Record Updated Successfully with the following details <br/>";
echo "debdes=$debdes <br>" ;
echo "debamt=$debamt <br>" ;
echo "crdes=$crdes <br>" ;
echo "cramt=$cramt <br>" ;
echo "date=$date <br>" ;
echo "end";
}
else
{
echo "Error while inserting data :".mysql_error()."<br/>";
}
.
.
.
there are two ways to do it:
- if you one of the fields that you are inserting is a primary key, then search the table for the record you updated, and then display the resultant data.
- If your primary key is generated automatically using
auto_increment
, then use mysql_insert_id.
Cheers,
jrh
精彩评论