Q:

Insert two arrays into one mysql table

I'm new at PHP and am stuck trying to insert data from two arrays into one mysql table.
The Table stores following fields: date, case_id, statusid
case_id would be the same for all records inserted in one statement and the value comes from a session variable.
the date array and status_id array are both being posted from a form; I know both arrays are posting fine because I've used a for each loop to insert both arrays to the table individually.
Any help will be much appreciated. I've left the foreach condition empty for suggestions.
$caseid = mysqli_real_escape_string($link, $_SESSION['caseid']);
$status = $_POST['statuses'];
$date = $_POST['dates'];

foreach() {
    $sql = " INSERT INTO casestatus (date, case_id, statusid) VALUE 
                                    ('$date', '$caseid', '$statusid') ";

    if (!mysqli_query($link, $sql)) {
        $error = 'Error assigning selected statuses to case.';
        include 'error.php';
        exit();
    }
}

A:

Try this.
// Avoid SQL Injections.
$caseid = mysqli_real_escape_string($link, $_SESSION['caseid']); 
$statuses = $_POST['statuses']; 
$dates = $_POST['dates'];

$i = 0;
foreach($statuses as $status)
{
  if($i < sizeof($dates))
  {
    $statusid = mysqli_real_escape_string($status);
    $date = mysqli_real_escape_string($dates[$i]); 
    $sql = "INSERT INTO casestatus (date, case_id, statusid) VALUES ('$date', '$caseid', '$statusid')";
    $i++:
  }
  // etc...
}

Don't forget to replace VALUE with VALUES in your INSERT statement.

