Advertisement
Guest User

Untitled

a guest
Oct 15th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.30 KB | None | 0 0
  1. <?php
  2. $servername = "192.168.142.2";
  3. $username = "DBAdmin";
  4. $password = "afis233";
  5.  
  6. // Create connection
  7. $conn = new mysqli($servername, $username, $password, "assignmentDB");
  8.  
  9. // Check connection
  10. if ($conn->connect_error) {
  11.     die("Connection failed: " . $conn->connect_error);
  12. }
  13. //echo "Connected successfully";
  14. $reciept_no = $_GET["reciept_no"] . "%";
  15. //print $reciept_no;
  16.  
  17. if ($_GET["action"] == "get_reciept") {
  18.  
  19.     $sql = "SELECT * FROM invoice "
  20.          . "JOIN owner ON invoice.customer_id = owner.owner_id "
  21.          . "JOIN vehicle ON owner.owner_id = vehicle.owner_id "
  22.          . "LEFT JOIN inspection ON inspection.vehicle_id = vehicle.vehicle_id "
  23.          . "LEFT JOIN branch ON branch.branch_id = inspection.branch_id "
  24.          . "WHERE invoice.invoice_id = ?";
  25.     $stmnt = $conn->prepare($sql); //compiles search_query
  26. }
  27.  
  28. if ($_GET["actions"] == "search_reciepts") {
  29.     $search_query = "SELECT invoice_id, description FROM invoice "
  30.                   . "WHERE invoice_id LIKE ?";
  31.  
  32.     $stmnt = $conn->prepare($search_query); //compiles search_query
  33. }
  34.  
  35. $stmnt->bind_param("s", $reciept_no); //substitutes ? for reciept_no
  36. $stmnt->execute();
  37. $rows = $stmnt->get_result();
  38. $rows = json_encode($rows->fetch_all());
  39. //print $sql;
  40.  
  41. //$rows = $conn->query($sql);
  42. print $rows;
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement