Random selects with PHP and Mysql

Asked

Viewed 85 times

2

Are there any way to make random selects with php and mysql.

Example:

1- I have the chart carreta_furacao:

id----nome
 1----Fofão
 2----Capitão América
 3----Popeye
 4----Mickey
 5----Palhaço 

2- In PHP I make a random select*

3-Returns id 1 and 3

4- I click the button to press more, and this activates another random select, this time there will be 2 other data except those with id 1 and 3 because these were already.

5- Cycle repeats until all items are listed

*I found several ways to make random selects on the web, but still do not know what is best, if anyone can help thank.

Note: Just to be clear, I know how to make selects and the like, the problem is how to do this "random function that does not repeat id’s"

  • 1

    If you want to eliminate some ai it is not random :P. vc can take the play array in the session and go removing the items from the start in pairs. This problem is similar to: Randomize results with PHP. Hurricane trailer :D

1 answer

2


You can store in an array all the ones going, query with ORDER BY RAND() and in the query make a SELECT WHERE id NOT IN ($suavariavel)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.