Is there possibly a way where I am able to randomly select rows from my database but override this if I want a row to be displayed.
For example, if I wanted to select 6 random rows where the username is Bob
but there is 1 important row which I want to be displayed with the usernameBob
, how would I select 5 random rows and the one important row?
My code currently:
$query = "SELECT * FROM user WHERE username LIKE '%".$_POST["query"]."%' OR email LIKE '%".$_POST["query"]."%' OR first_name LIKE '%".$_POST["query"]."%' OR last_name LIKE '%".$_POST["query"]."%' ORDER BY RAND() LIMIT 6";
Thanks in advance.
Aucun commentaire:
Enregistrer un commentaire