I am trying to post some table rows into a database. I have created a while loop and it keeps posting my first HTML table row to the database. The desired behaviour is that every HTML table row is posted to the DB.
<?PHP
$con=mysqli_connect("localhost","root","","freoplanner");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$count=1;
$shiftDate='dp'.$count;
$shiftTime='shiftTime'.$count;
$shiftAantal='shiftAantal'.$count;
while(isset($_POST[$shiftDate]) && !empty($_POST[$shiftDate])){
$sql="INSERT INTO shifts (datum, tijd, aantal)
VALUES
('$_POST[$shiftDate]','$_POST[$shiftTime]','$_POST[$shiftAantal]')";
$count++;
mysqli_query($con,$sql);
}
header("location:shiftstoevoegen.php");
?>