I am selecting 5 rows at random from a table.
$query = "SELECT stdid, name FROM students order by rand(UNIX_TIMESTAMP()) limit 5"
$myquery = mysqli_query($db_connect, $query);
while($students = mysqli_fetch_assoc($myquery)){
$stdid =$students['stdid']; $name = $students['name']; $dept = $students['dept'];
echo "<br><br>".$stdid."<br>".$name."<br>".$dept;
//NOT SURE IF I ADD INSERT HERE
}
I want to INSERT (5 rows) the displayed 'stdid' into another table.
Do i need to add the INSERT in the WHILE loop ? Is there another way to go about this ?
Many thanks.