Imagine I have a MySQL database table with 1,000 records in it and I wanted to select 1 record at random.
The records do not have an ID column where the numbers go up +1 each time. The ID numbers are randomly generated so the first records ID could be ‘932151540’ and the second records ID could be ‘541577961’.
The only way I can think of selecting 1 record at random is by finding out how many records there are in total. Pick a random number between 1 and however many there are (say the random number was 467). Then getting the 467th record.
How would I do this using PHP?
Thanks in advance 🙂
1 Answer