I've got a form which asks some basic questions about a job, and then asks to person entering to list all those colleagues that were with them at the time. What I want to do is for all colleagues present to have a row entered in to the database - so all the other details remain the same except for their work_id (which is the identifier for the person). My code below seems to submit 1 row to the db with the workID field empty
<?php
require_once('includes/dbconnect.php');
$varWorkID = $_POST['workid'];
$varDate = $_POST['date'];
$varType = $_POST['type'];
$varSuper = $_POST['supervisor'];
$varReference = $_POST['reference'];
//Remove last part of array as extra 1 sent through by form
$workID = array_pop($varWorkID);
for ($i=0; $i < count($workID); $i++ )
{
mysqli_query($conn,"INSERT INTO searches (workid,date,type,super,reference) VALUES('".$workID."','".$varDate."','".$varType."','".$varSuper."','".$varReference."')");
}
echo "Completed";
I think I'm fairly close but I just need to get workid to be populated with each of the Work IDs for each of the employees present.
Any assistance greatly appreciated