I want to make a basic forum for my website.
I have 2 tables for this:
table topics: fields id, title
table posts: fields id, topicid, message
When a user want’s to create a topic he has to complete a form with topic title and message. The title will be inserted in the topics table and the message in the posts table, but I will need topicid (field id in topics table) for the second insert.
INSERT INTO topics (title) VALUES ('$title')
INSERT INTO posts (topicid, message) VALUES ('???', '$message')
How can I get the topicid?
Mysql:
Or with PHP: