Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "192.168.142.2";
- $username = "DBAdmin";
- $password = "afis233";
- // Create connection
- $conn = new mysqli($servername, $username, $password, "assignmentDB");
- // Check connection
- if ($conn->connect_error) {
- die("Connection failed: " . $conn->connect_error);
- }
- //echo "Connected successfully";
- $reciept_no = $_GET["reciept_no"] . "%";
- //print $reciept_no;
- if ($_GET["action"] == "get_reciept") {
- $sql = "SELECT * FROM invoice "
- . "JOIN owner ON invoice.customer_id = owner.owner_id "
- . "JOIN vehicle ON owner.owner_id = vehicle.owner_id "
- . "LEFT JOIN inspection ON inspection.vehicle_id = vehicle.vehicle_id "
- . "LEFT JOIN branch ON branch.branch_id = inspection.branch_id "
- . "WHERE invoice.invoice_id = ?";
- $stmnt = $conn->prepare($sql); //compiles search_query
- }
- if ($_GET["actions"] == "search_reciepts") {
- $search_query = "SELECT invoice_id, description FROM invoice "
- . "WHERE invoice_id LIKE ?";
- $stmnt = $conn->prepare($search_query); //compiles search_query
- }
- $stmnt->bind_param("s", $reciept_no); //substitutes ? for reciept_no
- $stmnt->execute();
- $rows = $stmnt->get_result();
- $rows = json_encode($rows->fetch_all());
- //print $sql;
- //$rows = $conn->query($sql);
- print $rows;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement