Home > Backend Development > PHP Tutorial > PHP操作数据库有关问题

PHP操作数据库有关问题

WBOY
Release: 2016-06-13 10:10:53
Original
868 people have browsed it

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

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template