帮我看一下我的论坛文章添加代码,怎么样才能得到我刚刚发表的文章的ID号 高手帮忙

 所属目录:Java   |   类型:技术问答   |   时间:2007-05-21
 问题:

mysql的topic列是自动加1的。所以插入时topic_id值是空的。  
  但加入后我想返回刚刚发的帖子页面,就想csdn这样转。  
  但我怕如果用  
  "select   topic_id   from   topic   order   by   topic_time   desc   limit   1"  
  会得到其他的同时发的贴子(假设发贴人很多)  
   
  高手帮个忙,解决一下!小弟不胜感激!  
   
  $insertsql   =   sprintf("insert   into   topic   (topic_id,   forum_id,   user_name,   topic_face,   topic_title,   topic_content,   topic_time,   last_reply_time)   values   (%s,   %s,   %s,   %s,   %s,   %s,   %s,   %s)",  
                                                getsqlvaluestring($_post[topicid],   "int"),  
                                                getsqlvaluestring($_get[forumid],   "int"),  
                                                getsqlvaluestring($_post[username],   "text"),  
                                                getsqlvaluestring($_post[topicface],   "text"),  
                                                getsqlvaluestring($_post[topictitle],   "text"),  
                                                getsqlvaluestring($_post[topiccontent],   "text"),  
                                                getsqlvaluestring($date,   "date"),  
                                                getsqlvaluestring($date,   "date"));  
   
      mysql_select_db($database_bbs,   $bbs);  
      $result1   =   mysql_query($insertsql,   $bbs)   or   die(mysql_error());

· 网友精彩回答:

发表者:meteorlet

mysql_insert_id()

.
处理 SSI 文件时出错
© 2006-2008 All Rights Reserved