Hello
Thankyou for the replies.
So this
// select people from first table who are part of group 1
$query= "SELECT personID FROM people WHERE groupID = 1";
$result = mysql_query($query);
$numrows = mysql_num_rows($result);
while ($row = mysql_fetch_array($result) {
$personid = $row["personID"];
// add people to second table who are part of group 1
$query2 = "INSERT INTO people2 (peopleID, groupID) VALUES ('$personid', '1')";
$queryaddperson = mysql_query($query2) or die(mysql_error());
}
and this would do the exact same thing
// select people from first table who are part of group 1
$query= "SELECT personID FROM people WHERE groupID = 1";
$result = mysql_query($query);
$personid = array();
while ($row = mysql_fetch_array($result) {
array_push($personid, $row['personID'];
}
// add people to second table who are part of group 1
foreach($personid as $value){
$query2 = "INSERT INTO people2 (peopleID, groupID) VALUES ('$value', '1')";
$queryaddperson = mysql_query($query2) or die(mysql_error());
}