Commit 6f31ecae authored by Mihiranga G.L.V - IT18500790's avatar Mihiranga G.L.V - IT18500790

Merge branch 'IT18500790' into 'master'

Create trip plan

See merge request !15
parents 37648aa7 b6ca9b10
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$train_id = mysqli_real_escape_string($con,$_POST['train_id']);
$train_start_station = mysqli_real_escape_string($con,$_POST['train_start_station']);
$sql2 = "SELECT * FROM train_info WHERE logUserId = '$logUserid' AND train_id = '$train_id' AND train_start_station = '$train_start_station' ";
$result2 = mysqli_query($con,$sql2) or die(mysqli_error($con));
$row2 = mysqli_fetch_assoc($result2);
$train_arrival = $row2['train_arrival']; //Arrival Time
$train_date = $row2['train_date']; // Train Date
$sql1 = "SELECT * FROM best_seat WHERE `logUserid` = '$logUserid' AND `train_id` = '$train_id' AND `train_start_station` = '$train_start_station' AND `date` = '$train_date' AND `arrival` = '$train_arrival' ";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
$row1 = mysqli_fetch_assoc($result1);
$best_row = $row1['row'];
$best_pos = $row1['seat'];
echo $full_id_name = "seatbtn_".$best_row."_".$best_pos;
\ No newline at end of file
This diff is collapsed.
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$train_id = mysqli_real_escape_string($con,$_POST['train_id']);
$train_start_station = mysqli_real_escape_string($con,$_POST['train_start_station']);
$row = mysqli_real_escape_string($con,$_POST['row']);
$seat = mysqli_real_escape_string($con,$_POST['seat']);
$status = mysqli_real_escape_string($con,$_POST['status']);
$sql2 = "SELECT * FROM train_info WHERE logUserId = '$logUserid' AND train_id = '$train_id' AND train_start_station = '$train_start_station' ";
$result2 = mysqli_query($con,$sql2) or die(mysqli_error($con));
$row2 = mysqli_fetch_assoc($result2);
$train_arrival = $row2['train_arrival']; //Arrival Time
$train_date = $row2['train_date']; // Train Date
$sql1 = "SELECT * FROM select_seat_temp WHERE `logUserid` = '$logUserid' AND `train_id` = '$train_id' AND `train_start_station` = '$train_start_station' AND `row` = '$row' AND `seat` = '$seat' ";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
$rowcount1 = mysqli_num_rows($result1);
if($rowcount1 > 0) {
$sql3 = "DELETE FROM `select_seat_temp` WHERE `logUserid` = '$logUserid' AND `train_id` = '$train_id' AND `train_start_station` = '$train_start_station' AND `row` = '$row' AND `seat` = '$seat' ";
$result3 = mysqli_query($con,$sql3) or die(mysqli_error($con));
}
$sql4 = "INSERT INTO `select_seat_temp`(`logUserid`, `train_id`, `date`, `arrival`, `train_start_station`, `row`, `seat`) VALUES ('$logUserid', '$train_id', '$train_date', '$train_arrival', '$train_start_station', '$row', '$seat')";
$result4 = mysqli_query($con,$sql4) or die(mysqli_error($con));
if($result4){
?>
<button class="btn btn-success" onclick="selectSeat('<?php echo $logUserid ?>','<?php echo $train_id ?>','<?php echo $train_start_station ?>','<?php echo $row ?>','<?php echo $seat ?>','yes');" id="seatbtn_<?php echo $row ?>_<?php echo $seat ?>">1</button>
<?php
} else {
echo 0;
}
\ No newline at end of file
<?php
session_start();
include "db_connect.php";
$logUserid = mysqli_real_escape_string($con,$_POST['logUserid']);
$train_id = mysqli_real_escape_string($con,$_POST['train_id']);
$train_start_station = mysqli_real_escape_string($con,$_POST['train_start_station']);
$row = mysqli_real_escape_string($con,$_POST['row']);
$seat = mysqli_real_escape_string($con,$_POST['seat']);
$status = mysqli_real_escape_string($con,$_POST['status']);
$sql2 = "SELECT * FROM train_info WHERE logUserId = '$logUserid' AND train_id = '$train_id' AND train_start_station = '$train_start_station' ";
$result2 = mysqli_query($con,$sql2) or die(mysqli_error($con));
$row2 = mysqli_fetch_assoc($result2);
$train_arrival = $row2['train_arrival']; //Arrival Time
$train_date = $row2['train_date']; // Train Date
$sql1 = "SELECT * FROM select_seat_temp WHERE `logUserid` = '$logUserid' AND `train_id` = '$train_id' AND `train_start_station` = '$train_start_station' AND `date` = '$train_date' AND `arrival` = '$train_arrival' AND `row` = '$row' AND `seat` = '$seat' ";
$result1 = mysqli_query($con,$sql1) or die(mysqli_error($con));
$rowcount1 = mysqli_num_rows($result1);
if($rowcount1 > 0) {
$sql3 = "DELETE FROM `select_seat_temp` WHERE `logUserid` = '$logUserid' AND `train_id` = '$train_id' AND `train_start_station` = '$train_start_station' AND `date` = '$train_date' AND `arrival` = '$train_arrival' AND `row` = '$row' AND `seat` = '$seat' ";
$result3 = mysqli_query($con,$sql3) or die(mysqli_error($con));
}
if($result3){
?>
<button class="btn btn-primary" onclick="selectSeat('<?php echo $logUserid ?>','<?php echo $train_id ?>','<?php echo $train_start_station ?>','<?php echo $row ?>','<?php echo $seat ?>','no');" id="seatbtn_<?php echo $row ?>_<?php echo $seat ?>">1</button>
<?php
} else {
echo 0;
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment