我需要帮助我的web服务项目,用户创建订单时,提交订单,司机得到通知与接受或拒绝的订单,当他接受订单细节列表显示给他。所有这些过程都是通过提交订单完成的。我所有的编码都很好。我不知道从哪里得到当前订单清单的id。请给出解决方案。thx
<?php
if(isset($_POST['order_form']))
{
mysql_connect('localhost','root','');
mysql_select_db('live_help');
$user = $_POST['user'];
$password = $_POST['mobile'];
$password = $_POST['address'];
$password = $_POST['order_item'];
$password = $_POST['price'];
$sql= mysql_query("insert into `json_web`(user,mobile,address,order_item,price) values('$user','$mobile','$address','$order_item','$price')");
if($sql)
{
echo 'Value Saved';
}
}
?>
<form name="order_form" action="" method="post">
<input type="text" name="user">
<input type="text" name="mobile">
<input type="text" name="address">
<input type="text" name="order_item">
<input type="text" name="price">
<input type="submit" name="field1" value="Submit" />
</form>发布于 2014-10-07 06:27:18
使用mysql_insert_id();获取最后一个insert id。查看更多信息,id()
警告: mysql_*在PHP5.5.0中被取消,并将在将来删除。相反,应该使用MySQLi或PDO_MySQL扩展。还请参阅MySQL:选择API指南和相关常见问题以获得更多信息。这一职能的替代办法包括:
发布于 2014-10-07 06:26:43
在mysql_query()之后;您可以这样做:
$id = mysql_insert_id();mysql_insert_id();检索最后插入到数据库的元素的ID。
发布于 2014-10-07 06:30:35
使用来自mysqli_insert_id()的文档
mysqli::$insert_id -- mysqli_insert_id -返回上次查询中使用的自动生成的id。
https://stackoverflow.com/questions/26229779
复制相似问题