Jump to content

[SOLVED] randomly select from database?


techiefreak05

Recommended Posts

this might seem like a stupid question, i should be able to do this. but on the front page of my site i want a thing to show a few users. but i dont want it to show the same people over and over. i want it to select different people each time. any ideas?

 

EDIT: I already have a script that shows a few users, but it shows the same ones , i just need to know how to select different users from the database each time.

Link to comment
https://forums.phpfreaks.com/topic/44953-solved-randomly-select-from-database/
Share on other sites

Run a forum search for ORDER BY RAND() or something similar, and you'll find a bunch of discussions of the most optimal way to do what you're after. In short, you can try this (for 5 random users):

SELECT * FROM users ORDER BY RAND() LIMIT 5;

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.