kylewirth Posted August 31, 2010 Share Posted August 31, 2010 here is how my comment table is setup. id hashid1 hashid2 1 comment1 NULL 2 comment2 NULL 3 comment3 NULL 4 comment4 NULL 4 comment1 once someone creates a new thread, a new hashid3 column will be added. the problem i have is that once a new hashid column is created, all of the rows are filled with null. if someone comments on the second topic (hashid2) it starts on id=5, not 1. How can i have the table not fill up will null values and have new comments start at id=1 Quote Link to comment Share on other sites More sharing options...
JasonLewis Posted August 31, 2010 Share Posted August 31, 2010 Why don't you just have a topic_id column and a comment column. That way you don't need to create a new column for every new thread. Quote Link to comment Share on other sites More sharing options...
kylewirth Posted August 31, 2010 Author Share Posted August 31, 2010 are you talking about a setup like this: id comments_column 1 comment1 2 comment1 1 comment2 1 comment3 1 comment4 and then sort through to find. what if there are 100's of comments and 100's of topics? or like this... id comment1_column comment2_column 1 comment1 comment2 2 comment1 comment2 3 comment1 comment2 4 comment1 comment2 is this one even possible? Quote Link to comment Share on other sites More sharing options...
kylewirth Posted September 1, 2010 Author Share Posted September 1, 2010 hey all, i would like a little more input please. thanks Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted September 1, 2010 Share Posted September 1, 2010 You shouldn't need to alter your tables when a new thread or comment is added. You should set up two tables which are called threads, and comments. The basic table structure would be Threads ---------- thread_id auto_increment thread_title thread_poster thread_body Comments ------------- comment_id auto_increment thread_id comment_poster comment_body When you add a thread you insert it into the threads table. All comments to that thread will go into the comments table. You link the comment to the thread by inserting the threads id into the thread_id column within the comments table. The query you'd use to get all comments associated with the thread would be SELECT comment_title, comment_body, comment_author FROM comments WHERE thread_id='$thread_id' Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.