开发者

MYSQL- How do I create individual tables for forum posts?

For every forum post on my site, I'd like to create a MySQL table with the name of its id, in order to enable 开发者_运维知识库user commenting. The know-how will also come in handy when creating a table for each user registered, to enable friend tracking.

There are multiple posts across various sites about doing this. I figured that you need to prepare a statement and then append the $id variable to it- then execute. However, all the posts I've read about the topic were confusing and didn't work for me, so I'd like some advice. I am trying to create a table using PHP.

This is what the query should look like:

mysql_query("CREATE TABLE '$id' (...) ")

How do I prepare a statement? I don't really get it.

Or is there a better way to achieve my purpose than with prepared statements?

Thanks for any advice.


Don't create a table for each forum (or forum post, wasn't sure from your question). Simply create a table called comments and have a field in that table called 'forum_id'. When a user goes to create a comment on a forum or forum post, then have populate that field with the ID of the forum the user is commenting on. When pulling all comments back, just get all the comments for a particular forum based on the value of the forum_id field.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜