读书人

PHP操作数据库有关问题

发布时间: 2012-04-04 16:38:51 作者: rapoo

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

读书人网 >PHP

热点推荐