When I run this cart page, the booking.php and adminbooking.php is not working at all. There is not output or error but just blank page. This cart page is to take some database of user and car table. I really hope you guys can give me a solution for this problem. Thanks:)

This is for running mysql and sublime text.

I expect the output is can open "booking.php"

cart.php

<?php
    session_start(); 
    error_reporting(0);
    $db = mysqli_connect('localhost', 'root', '', 'online_car_rental');

    if (!isset($_SESSION['username'])) {
        $_SESSION['msg'] = "You must log in first";
        header('location: login.php');
    }

    if(isset($_GET['booking_id'])) {
        $item = $_GET['booking_id'];

        $querytotal_day = mysqli_query ($db,"SELECT total_day FROM car WHERE car_id = '$car_id'");
        $querytotal_dayrow = mysqli_fetch_assoc ($querytotal_day)
        $car_id = $querytotal_dayrow["car_id"];
        $total_daybooking = mysqli_query ($db,"SELECT total_daybooking FROM car WHERE car_id = '$car_id'");
        $q = mysqli_fetch_assoc ($total_daybooking);
        $total_day = (int) $q["total_daybooking"];
        $querytotal_dayint = (int) $querytotal_dayrow["total_day"];
        $remainingtotal_day = $querytotal_dayint + $total_day;
        $barang = "DELETE From booking WHERE booking_id='$item'";

        if ($db -> query($barang) === true) {
            echo '<script>alert("Delete successful!")</script>';
            mysqli_query($db, "UPDATE car SET total_day = '$remainingtotal_day'");
        } 
    }


    if (isset($_GET['logout'])) {
        session_destroy();
        unset($_SESSION['username']);
        header("location: login.php");
    }

    include('server.php');
?>


<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title>ONLINE CAR</title>
    <link rel="stylesheet" href="belumlogin.css">
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="index.css">
  </head>

  <body class="badan">
    <ul>
      <div class ="content">
          <center>
          <img src="car.jpg" alt="car" width="1500" height="250">
        </center>
      </div>
      <p>ONLINE CAR RENTAL</p>
        <a href="add.php?logout='1'" style="color: red;">LOGOUT</a>
        <li><a href="booking.php">BOOKING</a></li>
      <li><a href="car.php">CAR</a></li>
        <li><a> Welcome <strong><?php echo $_SESSION['username']; ?></strong> 
  </body>

  <body class="badan">
    <div class = "container">
    <div class = "index-box">
    <div class = "row">
    <div class = "col-md-12 index-mid">
    <h2>CART</h2>
    <style>
            table, td, th {
              border: 1px solid black;
              padding: 8px;
            }

            table {
              border-collapse: collapse;
              width: 100%;
            }

            th{
                background-color: #ddd;
            }

            td {
              height: 30px;
              vertical-align: bottom;
            }
        </style>
  </body>

  <table align='center' width='50%'>
    <tr>
      <th width='15%' align='center'>Image</th>
      <th width='15%' align='center'>Name</th>
      <th width='15%' align='center'>Total day booking</th>
      <th width='15%' align='center'>Total price (RM)</th>
    </tr>

<?php
    $carr = $_SESSION['username'];
    $carrlike = mysqli_query($db, "SELECT * FROM users WHERE  username = '$carr'");
    $carrlikee = mysqli_fetch_assoc($carrlike);
    $intcarrlike = (int) $carrlike['id'];

      $query = mysqli_query($db,"SELECT car.car_image, car.car_name, 
        booking.total_daybooking, booking.totalprice FROM 'car' INNER JOIN 
        'booking' ON car.car_id = booking.carID WHERE booking.custID = $intcarrlike" ); 

      if(mysqli_num_rows($query) > 0)
      {
          while($row = mysqli_fetch_array($query))
          {
                  $car_id = $row['car_id'];
                  $query2 = mysqli_query($db,"SELECT car_name FROM car WHERE car_id='$car_id'");
?>

      <tr>
        <td width='15%' align='center'>

    <?php
        echo "<img src='".$row['car_image']."'width = '100' height ='100'>"; 
    ?>
      </td>
        <th width='15%' align='center'><?php echo $row["car_name"]; ?>
      </td>
        <th width='15%' align='center'><?php echo $row["total_daybooking"]; ?> 
      </td>
        <th width='15%' align='center'><?php echo $row["totalprice"]; ?>
      </td>

    <?php 
    // delete 
    Print "<td width='15%' align='center'><button onclick='deleteor(" . $row["booking_id"] . ")'>Delete</button></td>";
    Print "<td width='15%' align='center'><button onclick='updatelist(" . $row["booking_id"] . ")'>Update</button></td>";
    ?>

    </tr>
    <?php 
        } //tutup while loop
    }else{
      echo "0 Results";
    }
    ?>
   </table>

 <?php //resit
     Print "<div align = 'right'><button style = 'width:100px' 
       onClick='receipt(" . $id . ")'>Receipt</button></div>";
 ?>

  <script>
    function deleteor( id ) {
      var r = confirm( "Are you sure you want to delete this order?" );
      if ( r == true ) {
        window.location.assign( "cart.php?booking_id=" + id );
      }
    }

    function updatelist( id ) {
      var r = confirm( "Are you sure you want to update this order?" );
      if ( r == true ) {
        window.location.assign( "car.php?booking_id=" + id );
      }
    }

    function receipt ( id ) {
      window.open("receipt.php?booking_id=" + id );
    }
    </script>
</html>

0 Answers