mercredi 30 novembre 2022

Random name from select database with variable [closed]

I have a problem of randomizing the names from a Mysql select, I tried with the RAND() function but with variable it gives me an error:

$sql_recup = "SELECT name, FROM `family` ORDER BY RAND() LIMIT 1 AND WHERE `family_id` = '" . $rows_block['id_yes'] . "'";

$result_recup = mysqli_query($db, $sql_recup);

$rows_recup = mysqli_fetch_assoc($result_recup);

trying on phpMyAdmin SELECT * FROM family ORDER BY RAND() LIMIT 1; so it works great, but putting the variable I can not figure out where I'm wrong. Thank you




Aucun commentaire:

Enregistrer un commentaire