print将值传递给Mysql

时间:2010-01-03 12:53:11

标签: php

我正在使用此代码向数据库添加值

  <?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 details <br/>";


else 

echo mysql_error(); 



?>

现在我希望在查询传递时告诉我显示哪些值是这样添加的

“以下记录已成功更新

debamt = 1000 debdes = test

结束“

2 个答案:

答案 0 :(得分:0)

有两种方法可以做到:

  1. 如果您要插入的某个字段是主键,则在表中搜索您更新的记录,然后显示结果数据。
  2. 如果您的主键是使用auto_increment自动生成的,请使用mysql_insert_id
  3. 干杯,
    JRH

答案 1 :(得分:0)

如果查询未失败,您只需显示您的值:


.
.
.
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/>"; 
}
.
.
.