So here is my problem. I have developed guestbook's and comment systems before, however they were simply used on one page and used the auto increment feature to seperate enteries. Each entry was stored on a seperate row in my database and they were organized by an array when called.

My current project uses a template and creates a new page for each "id" and the page is populated by the variables from that row. So basically all of my variables have to be stored in the same row.

I now cannot figure out how to create a comment system that stores each entry on the same row as all of the other features on my pages, because the auto increment "id" is already being used. I tried changing it to "commentid" and auto incrementing that, however this created new rows in my table, and that cant happen.

An example of my format would be path/profile.php?id=1, so each page is determined by the id.

Does anyone have any ideas or suggestions as to how I could acheive a comment system that stores each entry in the same row? I have seen this done on many websites, but can find no guides or code examples for it.

Any help is greatly apreciated.

store comments in a separate table and reference them by id. it would be very inefficient to store them in the same row.

store comments in a separate table and reference them by id. it would be very inefficient to store them in the same row.

Ah hey kkeith,

I did consider that an option, however because of my PHP skill level I wasnt able to figure out exactly how to tie in the new table to my pages. I know how to create the table and I know how to insert entries into the table, I just dont know how to make sure that the correct page (based on $id, still using the same method you taught me last week) gets the correct entries.

Sorry if I am wrong, but what it looks to me is that you're in need of a another table.
oK here what you have to do,

in the second table you insert the comments, each comment has its own ID that increments, and each comment has a column named thread_id.

so if 5 people post at the same forum that has the ID=33 then the rows will look like this

ID thread_id comment
1 33 a com
2 33 2 com
3 33 3 com

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.