I am trying to get the result of a table and insert it into another table. The results are user id's. This code should work, but it doesn't.
$query1 = "SELECT id FROM users";
$select1 = $db->prepare($query1);
$select1->execute(array());
foreach($select as $index => $rs) {
$users = $rs['id'];
// the results are 1,2,3,4,5,6,7,8... (the user id's)
}
// Here below, I want to add the results into another table...
foreach ($users as $row){
$query2 = "INSERT INTO validateuser (userid) VALUES (".$row.")";
$select2 = $db->prepare($query2);
$select2->execute(array());
}