开发者

posting into two linked tables

开发者 https://www.devze.com 2023-01-09 13:23 出处:网络
I want to post something to my database which consists of two tables which are linked with a foreign key. I want to be able to post something to the first table which has only two cells (city and city

I want to post something to my database which consists of two tables which are linked with a foreign key. I want to be able to post something to the first table which has only two cells (city and city_id) via php and then get redirected to the second table where someone can post detail about places of the city (houses squares ect (city_id is the foreign key here)) whith an one-to-many relationship. How can I do that? Should I write two php files and how can I connect th开发者_开发知识库e two tables?


You can insert the city records, use mysql_insert_id() after the insert to get the cityid for the inserted record, and then redirect to a details posting page with e.g. a URL parameter for the cityid.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号