I'm trying make array for emp_no from empregtable and to store array result into another table message (separate rows). I have code something like that. but it is not working. Please if anyone can help me on this, Thanks.
$selectresult = mysqli_query($dbc,"SELECT emp_no FROM empreg");
$result_array = array();
while($row = mysqli_fetch_assoc($selectresult))
{
$result_array[] = $row['emp_no'];
}
$values= serialize($_POST["emp_no"]);
foreach($values as $result)
{
$sendmessage = mysqli_query ($dbc,"INSERT INTO message (to_user, date,message_title,message_contents) VALUES ('$values', '$date' ,'$subject','$message')");
}
empreginto$result_array- but then you aren't using it anywhere. Then you are inserting the entire array from$valuesinto themessagetable. Surely you meant to use this variable:$result?