开发者

print passes values to Mysql

开发者 https://www.devze.com 2022-12-15 03:22 出处:网络
i am using this code to add values to database <?php $debdes = $_POST[\'debdes\']; $debamt = $_POST[\'debamt\'];

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:

  1. 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.
  2. If your primary key is generated automatically using auto_increment, then use mysql_insert_id.

Cheers,
jrh

0

精彩评论

暂无评论...
验证码 换一张
取 消