aviatorisu Posted May 22, 2006 Share Posted May 22, 2006 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 https://forums.phpfreaks.com/topic/10157-question-about-loops/ Share on other sites More sharing options...
KrisNz Posted May 22, 2006 Share Posted May 22, 2006 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 https://forums.phpfreaks.com/topic/10157-question-about-loops/#findComment-37864 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.