Let me explain the situation here. I have a page called travel.php. I want to submit a form in the travel.php. In this form, it contains few input at the top, and after that below it have a 2 tabs (hotel tab and airplane tab). In each tabs have a table input (which able to add row).
Below is an example (not fully. Just showing the flow) of submit FORM code which is working, but this code i only include one tabs which only got one table (which able to add row). Based on the code below what can i do if i have a 2 tabs (hotel tab and airplane tab). In each tabs have a table input (which able to add row).
<?php
if(isset($_POST['travel']))
{
//Do smth
//List $_POST
for ($i = 0; $i < count($_POST["merchant"]); $i++)
{
$merchant = $_POST["merchant"][$i];
$remark = $_POST["remark"][$i];
$docno = $_POST["docno"][$i];
$date = $_POST["date"][$i];
$category = $_POST["category"][$i];
$claim_amount = $_POST["claim_amount"][$i];
$targetPath="upload/";
$file = $targetPath.rand(1000,100000)."-".$_FILES['bill_image']['name'][$i];
$file_loc = $_FILES['bill_image']['tmp_name'][$i];
$file_basename = substr($file, 0, strripos($file, '.'));
move_uploaded_file($file_loc,$file);
$save_new_record = "INSERT INTO `report`...";
$stmt5 = $mysqli->prepare($save_new_record);
$stmt5->bind_param('ssiis', $reportName, $report_number, $euser);
if ($stmt5->execute() == false){
echo 'Fifth query failed: ' . $mysqli->error;
}
$stmt5->close();
}
$title = $mysqli->real_escape_string($_POST["title"]);
$mode = $mysqli->real_escape_string($_POST["mode"]);
$from_date = $mysqli->real_escape_string($_POST["from_date"]);
$to_date = $mysqli->real_escape_string($_POST["to_date"]);
$timefrom = $mysqli->real_escape_string($_POST["timefrom"]);
$timeto = $mysqli->real_escape_string($_POST["timeto"]);
$save_report_s = "INSERT INTO `traveling` () VALUES ()";
$save_report_ss = "INSERT INTO `report_s`() VALUES ()";
$stmt3 = $mysqli->prepare($save_report_s);
$stmt6 = $mysqli->prepare($save_report_ss);
$stmt3->bind_param('', $);
$stmt6->bind_param('', $);
if ($stmt6->execute() == false){
echo 'gl A query failed: ' . $mysqli->error;
} else {
if ($stmt3->execute() == false){
echo 'gl B query failed: ' . $mysqli->error;
}
$stmt3->close();
}
$stmt6->close();
}
?>
i hope someone can give me hints how i can single submit a form where inside a form have a few input field at the top (will insert into database table called "TRAVELING")and at bottom have 2 tabs, in those two tabs have it owns table input (dynamically add rows table).. The table in each tabs have a slightly different attributes but it will be insert into same database TABLE called "RECORD". This i found a short and easy to view example (which involve one table only) CLICK but my problem is how can i submit form when there are two tabs at below and in each of tab have its own table.