dongwu1410 2013-08-12 09:57
浏览 360
已采纳

如何使用php获取mysql的最后一个ID

I have a form with two stages, the first is to put the information but the second is the UPDATE to add the photo. So what I want to do is retrieve the last auto incremented ID to update the data, I used LAST_INSERT_ID ()

but I realize it is the update everywhere. Do you have a suggestion for me to help me? Thank you and sorry sorry for my english.

You can see here what I did:

 $sql = 'UPDATE 'jj_news' SET 
cover_picture="'.$large_image_name.$_SESSION['user_file_ext'].'",
 min_picture="'.$thumb_image_name.$_SESSION['user_file_ext'].'", statut="1",
 edited="'.date('Y-m-d h:i:s').'" WHERE id_news= LAST_INSERT_ID(id_news)';
       mysql_query($sql) or die('Erreur SQL !'.$sql.'<br />'.mysql_error());
  • 写回答

4条回答 默认 最新

  • doushi3454 2013-08-12 11:44
    关注

    Bloody hell, why don't you just store the damn id, into a hidden post field and pass it to the second page on form submit?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集