Jump to content

[SOLVED] Comments in Blog/News Script I'm working on.


beaux1

Recommended Posts

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.