beaux1 Posted June 7, 2007 Share Posted June 7, 2007 Hey guys. I'm working on my own blog/news script, and I'm about to work on the comments system. My MySQL database is plotted out like so: ID name date subject msg Alright, simple enough. But, what would the best way going about the comments in my script? I'm just not sure about how to go about this, I understand inserting data (in this case the comments) into the database, but how would I go about doing it in general? I'm not making much sense, I know, I know, but could someone please guide me in the right direction? Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/54586-solved-comments-in-blognews-script-im-working-on/ Share on other sites More sharing options...
iceblox Posted June 7, 2007 Share Posted June 7, 2007 so i can understand you have a your news page then you want people to add comments to that? Quote Link to comment https://forums.phpfreaks.com/topic/54586-solved-comments-in-blognews-script-im-working-on/#findComment-269914 Share on other sites More sharing options...
beaux1 Posted June 7, 2007 Author Share Posted June 7, 2007 Yeah, I know I have a box, the user can enter comments, and the database will retrieve the information and display all the comments, but how do I go about splitting the comments up? Let's say I have: ID name date subject msg comments 1 test 1/1/1 cereal test How would I go about splitting the comments up and knowing which is which etc? Quote Link to comment https://forums.phpfreaks.com/topic/54586-solved-comments-in-blognews-script-im-working-on/#findComment-269915 Share on other sites More sharing options...
iceblox Posted June 7, 2007 Share Posted June 7, 2007 for my reviews site which is done similarly i use a table to seperate them like this $query = "SELECT * FROM reviews WHERE modid = '$modid' ORDER BY revid DESC"; $result = mysql_query($query); while($row = mysql_fetch_row($result)) if (mysql_num_rows($result) > 0) { if($rowcounter%2==1) $bgcolor="#87C542"; else $bgcolor="#D9E8B1"; echo '<br><table border="0" cellpadding="0" cellspacing="5" bordercolor="#111111" width="630" bgcolor="' . $bgcolor . '"> <tr> <td width="40%"><center><b>Review added by '. $row[3].'</b></center></td> <td width="60%"><img border="0" src="images/articles/stars-'. $row[5].'.gif" width="64" height="12"></td> </tr> <tr> <td width="100%" colspan="2">'. $row[6].'</td> </tr> </table>'; $rowcounter++; Or am i still missing the point? Quote Link to comment https://forums.phpfreaks.com/topic/54586-solved-comments-in-blognews-script-im-working-on/#findComment-269918 Share on other sites More sharing options...
beaux1 Posted June 7, 2007 Author Share Posted June 7, 2007 Ehm, hmm, well, I was thinking, having a table called comments, which stores the comments, but how would I go about linking or making them relevent to the blog post itself? I was thinking of making a column called blogid, and when a user submits a comment, it inserts the blogid into that, so therefore I can call all comments WHERE blogid = 2, for example. I'm sure that would work fine, but is it a messy workaround to do what I'm trying to achieve? Quote Link to comment https://forums.phpfreaks.com/topic/54586-solved-comments-in-blognews-script-im-working-on/#findComment-270018 Share on other sites More sharing options...
iceblox Posted June 7, 2007 Share Posted June 7, 2007 thats how i have had to do mine. Its the quickest and easiet way to do it from what i have been told. But it works great for me Quote Link to comment https://forums.phpfreaks.com/topic/54586-solved-comments-in-blognews-script-im-working-on/#findComment-270135 Share on other sites More sharing options...
beaux1 Posted June 7, 2007 Author Share Posted June 7, 2007 Sweet, thanks alot man. I'll do it that way then. Quote Link to comment https://forums.phpfreaks.com/topic/54586-solved-comments-in-blognews-script-im-working-on/#findComment-270224 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.