Jump to content

Comments


onthespot

Recommended Posts

Hey guys

I have three different places on my site at present where people can comment.

They enter three tables called, comments, leaguecomments and newscomments.

 

I have a place where it displays the last 5 comments in desc order from the table comments.

I am looking for it to display the last 5 comments ordered by the date from all three tables.

So 5 comments that are the newest over the all three tables.

 

 <?
$res=mysql_query("SELECT SUBSTRING(comment, 1, 13) as comment, touser FROM ".TBL_COMMENTS." ORDER BY commentdate DESC LIMIT 5") or die(mysql_error);
		while($row=mysql_fetch_assoc($res)){
		$comment=$row['comment'];
		$touser=$row['touser'];
		?>
        <li><a href="userprofile.php?user=<?echo $touser?>#comments"><?echo "$comment";?>...</a></li>
		<?
		}
?>

 

That works for one table, how can I combine all three?

Thanks

Link to comment
Share on other sites

I would change your table structure a bit.  Instead of having 3 separate tables. Try this

 

Categories

Category, CategoryID

 

category being News, League, etc

 

Comments

CommentID, CategoryID, UserID, Comment, CommentDate

 

then you put all comments in that table and you just separate them by the category as you need to.

 

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.