日期:2014-05-17  浏览次数:20496 次

PHP操作数据库问题
问题:
        有两个表:   table1,table2
        table1里的字段有:
        id     title   content

        table2里的字段有:
        id   cid   user      

其中CID为table1中的ID

table1通过   insert   into   生成一个数据后,同时将table1中的   id   写到table2中,怎么实现啊?  

如下:
table1:
id   title       content
1       test         内容
2       test2       内容2

table2:
id   cid       user
1       1         用户
2       2         用户2


谢谢~~



------解决方案--------------------
mysql_insert_id();
取得上一步 INSERT 操作产生的 ID 再插入table2