I want to be able to select a STUDENT randomly who has not FACED the exam ('N') and echo the name and subject. How can I achieve this?
$query = $db->prepare('SELECT name FROM exams WHERE faced = ?');
$array = array('N');
$query->execute($array);
You can use something like:
$query = $db->prepare('SELECT name, subject
FROM exams WHERE faced = ?
ORDER BY RAND() LIMIT 1');
$array = array('N');
$query->execute($array);
$result = $query->fetchAll(PDO::FETCH_COLUMN, 0);
var_dump($result);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With