Jump to content

Question about loops


aviatorisu

Recommended Posts

Hi all, looking for a little help here.

I'm designing a website to review restaurants, shows, etc. around town, and I've learned quite a bit so far during this time. Each review is going to have a section allowing members to post their own comments. I've started into this script, and have a question about how to display the info. I only want to display 2 or 3 random comments for that particular place being reviewed. What would be the best way to go about picking out the comments from the database and then displaying them? Is there a way to limit the results? What if only 1 comment has been left, will it display the same comment to the max number of results?

Thanks in advance.

~Z~
Link to comment
Share on other sites

from the mysql manual

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]
ORDER BY RAND() combined with LIMIT is useful for selecting a random sample of a set of rows:

mysql> SELECT * FROM table1, table2 WHERE a=b AND c<d
-> ORDER BY RAND() LIMIT 1000;
[/quote]
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.