if($triptype == 'outstation') {
if(isset($_POST['oneway_travel_det1'])) {
$travelDet = parseValues($_POST['oneway_travel_det1']);
foreach ($travelDet as $det) {
if(isset($det['to_airport'])) {
$toAirport = $det['to_airport'];
}
else {
$toAirport = 0;
}
if(isset($det['from_airport'])) {
$fromAirport = $det['from_airport'];
}
else {
$fromAirport = 0;
}
$amt = (!empty($det['est_cost'])) ? $det['est_cost'] : 0;
$dep_place = $arr_place = '';
$dep_place = (!empty($det['dep_ocity1'])) ? $det['dep_ocity1'] : $det['dep_oplace1']; //get entered city for international
$arr_place = (!empty($det['arr_ocity1'])) ? $det['arr_ocity1'] : $det['arr_oplace1']; //get entered city for international
//insert query
$query = "INSERT INTO `tools_taxi`.`trip_itenary`(`trip_id`,`departure`,`departure_country`,`arrival`,`arrival_country`,`dept_date`,`dept_time`, `trip_type`) VALUES ('".$taxi_id."','" . $dep_place . "','" . $det['dep_oplace1'] . "','" . $arr_place . "','" . $det['arr_oplace1'] . "','" . date('Y-m-d', strtotime($det['dep_date'])) . "','" . $det['time_zone3'] . "', '".$type_of_trip."')";
echo "INSERT INTO `tools_taxi`.`trip_itenary`(`trip_id`,`departure`,`departure_country`,`arrival`,`arrival_country`,`dept_date`,`dept_time`, `trip_type`) VALUES ('".$taxi_id."','" . $dep_place . "','" . $det['dep_oplace1'] . "','" . $arr_place . "','" . $det['arr_oplace1'] . "','" . date('Y-m-d', strtotime($det['dep_date'])) . "','" . $det['time_zone3'] . "', '".$type_of_trip."')";
$res = mysqli_query($taxi_conn, $query);
if (!$res) {
die('bta_travel_itenary table insert failed' . mysqli_error($taxi_conn));
trace_log(__FILE__, __LINE__, $taxi_id . " : " . $query . mysqli_error($taxi_conn));
}
else{
trace_log(__FILE__, __LINE__, $taxi_id . " : History Updated Sucessfully.");
}
}
}
// }
else {
$travelDet = parseValues($_POST['round_travel_det1']);
foreach ($travelDet as $det) {
$amt = (!empty($det['est_cost'])) ? $det['est_cost'] : 0;
$dep_place = $arr_place = '';
$dep_place = (!empty($det['dep_rcity1'])) ? $det['dep_rcity1'] : $det['dep_rplace1']; //get entered city for international
$arr_place = (!empty($det['arr_rcity1'])) ? $det['arr_rcity1'] : $det['arr_rplace1']; //get entered city for international
//insert query
$query = "INSERT INTO `tools_taxi`.`trip_itenary`(`trip_id`,`departure`,`departure_country`,`arrival`,`arrival_country`,`dept_date`,`dept_time`, `trip_type`) VALUES ('".$taxi_id."','" . $dep_place . "','" . $det['dep_rplace1'] . "','" . $arr_place . "','" . $det['arr_rplace1'] . "','" . date('Y-m-d', strtotime($det['dep_date'])) . "','" . $det['time_zone3'] . "', '".$type_of_trip."')";
echo "INSERT INTO `tools_taxi`.`trip_itenary`(`trip_id`,`departure`,`departure_country`,`arrival`,`arrival_country`,`dept_date`,`dept_time`, `trip_type`) VALUES ('".$taxi_id."','" . $dep_place . "','" . $det['dep_rplace1'] . "','" . $arr_place . "','" . $det['arr_rplace1'] . "','" . date('Y-m-d', strtotime($det['dep_date'])) . "','" . $det['time_zone3'] . "', '".$type_of_trip."')";
$res = mysqli_query($taxi_conn, $query);
if (!$res) {
die('trip_itenary table insert failed' . mysqli_error($taxi_conn));
trace_log(__FILE__, __LINE__, $taxi_id . " : " . $query . mysqli_error($taxi_conn));
}
else{
trace_log(__FILE__, __LINE__, $taxi_id . " : History Updated Sucessfully.");
}
}
}
}
//
elseif($triptype == 'city') {
if (isset($_POST['oneway_travel_det'])) {
/*One way travel*/
$travelDet = parseValues($_POST['oneway_travel_det']);
foreach ($travelDet as $det) {
$amt = (!empty($det['est_cost'])) ? $det['est_cost'] : 0;
$dep_place = $arr_place = '';
$dep_place = (!empty($det['dep_ocity'])) ? $det['dep_ocity'] : $det['dep_oplace']; //get entered city for international
$arr_place = (!empty($det['arr_ocity'])) ? $det['arr_ocity'] : null; //get entered city for international
//insert query
$query = "INSERT INTO `tools_taxi`.`trip_itenary`(`trip_id`,`departure`,`departure_country`,`arrival`,`dept_date`,`dept_time`, `trip_type`) VALUES ('".$taxi_id."','" . $dep_place . "','" . $det['dep_oplace'] . "','" . $arr_place . "','" . date('Y-m-d', strtotime($det['dep_date'])) . "','" . $_POST['time_zone3'] . "', '".$type_of_trip."')";
echo "INSERT INTO `tools_taxi`.`trip_itenary`(`trip_id`,`departure`,`departure_country`,`arrival`,`dept_date`,`dept_time`, `trip_type`) VALUES ('".$taxi_id."','" . $dep_place . "','" . $det['dep_oplace'] . "','" . $arr_place . "','" . date('Y-m-d', strtotime($det['dep_date'])) . "','" . $_POST['time_zone3'] . "', '".$type_of_trip."')";
$res = mysqli_query($taxi_conn, $query);
if (!$res) {
die('bta_travel_itenary table insert failed' . mysqli_error($taxi_conn));
trace_log(__FILE__, __LINE__, $taxi_id . " : " . $query . mysqli_error($taxi_conn));
}
else {
trace_log(__FILE__, __LINE__, $taxi_id . " : History Updated Sucessfully.");
}
}
}
}
else {
if (isset($_POST['round_travel_det'])) {
/*Round Trip Travel*/
$travelDet = parseValues($_POST['round_travel_det']);
foreach ($travelDet as $det) {
$amt = (!empty($det['est_cost'])) ? $det['est_cost'] : 0;
$dep_place = $arr_place = '';
$dep_place = (!empty($det['dep_rcity'])) ? $det['dep_rcity'] : $det['dep_rplace']; //get entered city for international
$arr_place = (!empty($det['arr_rcity'])) ? $det['arr_rcity'] : null; //get entered city for international
//insert query
$query = "INSERT INTO `tools_taxi`.`trip_itenary`(`trip_id`,`departure`,`departure_country`,`arrival`,`dept_date`,`dept_time`, `trip_type`) VALUES
('".$taxi_id."','" . $dep_place . "','" . $det['dep_rplace'] . "','" . $arr_place . "','" . date('Y-m-d', strtotime($det['dep_date'])) . "','" . $det['time_zone3'] . "', '".$type_of_trip."')";
echo "INSERT INTO `tools_taxi`.`trip_itenary`(`trip_id`,`departure`,`departure_country`,`arrival`,`dept_date`,`dept_time`, `trip_type`) VALUES
('".$taxi_id."','" . $dep_place . "','" . $det['dep_rplace'] . "','" . $arr_place . "','" . date('Y-m-d', strtotime($det['dep_date'])) . "','" . $det['time_zone3'] . "', '".$type_of_trip."')";
$res = mysqli_query($taxi_conn, $query);
if (!$res) {
die('trip_itenary table insert failed' . mysqli_error($taxi_conn));
trace_log(__FILE__, __LINE__, $taxi_id . " : " . $query . mysqli_error($taxi_conn));
}
else{
trace_log(__FILE__, __LINE__, $taxi_id . " : History Updated Sucessfully.");
}
}
}
}
As shown in the above code I am trying to insert the values in the database. The problem here is that when I try to insert values wrt âoutstationâ condition, only the if condition is executing i.e., $_POST[âoneway_travel_det1â] and not the $_POST[âround_travel_det1â]. When I enter data wrt round trip the details are not getting inserted. Please let me know if there is anything wrong.