Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

ruzalo / airline-booking

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Members
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Switch branch/tag
  • airline-booking
  • php_files
  • admin_delete_record_database.php
Find file
BlameHistoryPermalink
  • Ryo's avatar
    Uploaded php_files folder · 71111947
    Ryo committed 5 years ago
    71111947
admin_delete_record_database.php 2.53 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
<?php
    #echo "Insert new user";
// connect to the database
//$con = mysqli_connect(localhost,root, root, Airline_Booking, 8889);
$con = mysqli_connect("anysql.itcollege.ee", "WT16", "iLtQlUerkT", "WT16");

// Check connection
if (mysqli_connect_errno()) {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
}

//$data = mysqli_query($con, "SELECT Passenger_Id FROM Passenger_Profile WHERE First_Name = '$First_Name' AND Last_Name = '$Last_Name' AND Flight_Number = '$Flight_Number'");

$data = mysqli_query($con, "SELECT Profile_Id FROM Passenger_Profile WHERE First_Name = '$First_Name' AND Last_Name = '$Last_Name'");
//And display the results
while($row = mysqli_fetch_array( $data )) {
 // echo "$row[0]". " ";
 // echo "<br>";
 $Profile_Id = $row[0];
 echo $Profile_Id;
}

$data2 = mysqli_query($con, "SELECT Flight_Id FROM FlightData WHERE Flight_Number = '$Flight_Number'");
while($row2 = mysqli_fetch_array( $data2 )) {
 // echo "$row[0]". " ";
 // echo "<br>";
 $Flight_Id = $row2[0];
 echo $Flight_Id;
}

//And display the results
// while($row = mysqli_fetch_array( $data )) {
//   echo "$row[0]". " ";
//   echo "<br>";
//
// }

//This counts the number or results. If there aren't any, it gives the user a "no match" message
$anymatches=mysqli_num_rows($data);
if ($anymatches == 0) {
 echo "Sorry, but we can not find an entry to match your query<br><br>";
}

//And reminds the user what they searched for
// echo "<b>Searched For:</b> " . "$find";
// }

  //break;
//
// if (isset($_GET['Passenger_Id#
// '])) {
//
// 	$Passenger_Id = $_GET['Passenger_Id'];
// 	echo $Passenger_Id;

// }
echo "Your input:::::::::<br>";
echo "".$First_Name. "<br>";
echo "".$Last_Name. "<br>";
echo "".$Flight_Number. "<br>";

$data4 = mysqli_query($con, "DELETE FROM Ticket_Info WHERE Profile_Id = '$Profile_Id' AND Flight_Id = '$Flight_Id'");
if (mysqli_query($con, $data4)) {
   echo "Record deleted successfully";
}
else {
 echo "Error deleting record: " . mysqli_error($con);
}

//sql to delete a record
$data3 = mysqli_query($con, "DELETE FROM Passenger_Profile WHERE Profile_Id = '$Profile_Id'");
if (mysqli_query($con, $data3)) {
   echo "Record deleted successfully";
}
else {
 echo "Error deleting record: " . mysqli_error($con);
}



// mysqli_query($con, "DELETE FROM Ticket_Info WHERE Passenger_fk = $row[0]");
// printf("Affected rows (DELETE): %d\n", mysqli_affected_rows($con));
// if (mysqli_query($con, $data)) {
//     echo "Record deleted successfully";
// } else {
//     echo "Error deleting record: " . mysqli_error($con);
// }

mysqli_close($con);
?>