lAZLf Posted December 14, 2009 Share Posted December 14, 2009 on my website, I display posts/updates on the website's development, and I'm trying to make it so that with each post, a viewer can post a comment on it. I can't figure out how to make it so that each post can show different comments. sorry if i'm not being so clear. where the posts are displayed: while($row=mysql_fetch_array($result)){ echo' <tr> <td height="20" class="title">'.$row['title'].'</td><td class="title"><div align="right">'.$row['date'].' </div> </td> </tr> <tr> <td height="100" colspan="2" class="content">'.$row['content'].' </td> </tr> <tr><td> <a href="javascript:toggle_visibility()" class="link">[comments]</a> <div id="comments">hi</div> </td></tr>'; } Quote Link to comment https://forums.phpfreaks.com/topic/185149-comment-on-a-post-problem/ Share on other sites More sharing options...
mikesta707 Posted December 14, 2009 Share Posted December 14, 2009 That code doesn't help at all. How is your database configured. What tables do you have, and what columns are in those tables. At least post the query itself? Quote Link to comment https://forums.phpfreaks.com/topic/185149-comment-on-a-post-problem/#findComment-977367 Share on other sites More sharing options...
lAZLf Posted December 14, 2009 Author Share Posted December 14, 2009 SELECT * FROM Archive ORDER BY date DESC My table for the posts has the columns of "title", "content" and "date". That part works fine (http://annarboruncovered.com/). I'm going to set up a table for the comments with the columns of "content", "poster" and "date". Quote Link to comment https://forums.phpfreaks.com/topic/185149-comment-on-a-post-problem/#findComment-977370 Share on other sites More sharing options...
mikesta707 Posted December 14, 2009 Share Posted December 14, 2009 you are also going to want to make a column in the comments table with a link for the Archive table (IE the primary key, title, etc) and then you could use that in the query Quote Link to comment https://forums.phpfreaks.com/topic/185149-comment-on-a-post-problem/#findComment-977372 Share on other sites More sharing options...
lAZLf Posted December 14, 2009 Author Share Posted December 14, 2009 What do you mean when you say "with a link for the Archive table"? And how could I use it in the query? Quote Link to comment https://forums.phpfreaks.com/topic/185149-comment-on-a-post-problem/#findComment-977375 Share on other sites More sharing options...
mikesta707 Posted December 14, 2009 Share Posted December 14, 2009 a column that you can store something unique at each article. For each article you could do something like SELECT * FROM comments WHERE archive_id=? and archive_id stores, say, the unique id's from the Archive table, or something to that will identify which article you are talking about Quote Link to comment https://forums.phpfreaks.com/topic/185149-comment-on-a-post-problem/#findComment-977380 Share on other sites More sharing options...
lAZLf Posted December 14, 2009 Author Share Posted December 14, 2009 I see what you mean, but wouldn't the fact that it's in a "while" statement (original code) get in the way? Quote Link to comment https://forums.phpfreaks.com/topic/185149-comment-on-a-post-problem/#findComment-977384 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.