Click here to Skip to main content
15,851,711 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<?php
session_start();

require("connect.php");
if(!isset($_SESSION['email'],$_SESSION['password']))
{
    header("location:login.php");
}


$query=" SELECT `fname`,`lname`,`appointment_date`,`appointment_time`,`message`,`remark`,`status` FROM `appointments` INNER JOIN `patients` ON appointments.patientid= patients.id INNER JOIN doctors ON appointments.doctor_id=doctors.id";
$result=mysqli_query($con,$query);

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>DAMS</title>

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
    <link rel="stylesheet" href="assets/css/style.css">
    <!-- <link rel="stylesheet" href="assets/css/bootstrap.min.css"> -->
     

    
</head>
<body>

<div class="container-fuid bg-blue shadow-sm ">  
    <div class="container pb-2 pt-2 d-grid gap-2">
       <div class="dropdown">
       <a class="navbar-brand text-white h1" href="admin_dashboard.php">DOCTOR APPOINTMENT MANAGEMENT SYSTEM   (DAMS)</a>                        
       
       <a class="navbar-brand text-white h2" href="admin_dashboard.php"><img src="images/dash.png" alt=""width="26px" height="26px"> Dashboard</a> 
       <button class="btn btn-primary dropdown-toggle navbar-brand text-white h2" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false"
        >Manage Users</button>
       

        <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
         <li><a class="dropdown-item" href="select_patients.php">Patients</a></li>
         <li><a class="dropdown-item" href="select_doctors.php">Doctors</a></li>
         <li><a class="dropdown-item" href="add_doctor.php">Add Doctor</a></li>
         <li><a class="dropdown-item" href="add_specs.php">Add Specilizations</a></li>
       
      </ul>
        <button class="btn btn-primary dropdown-toggle navbar-brand text-white h2" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false"
        >Appointments</button>
       

      <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
         <li><a class="dropdown-item" href="admin_approved_appointments.php">Approved Appointment</a></li>
         <li><a class="dropdown-item" href="admin_cancelled_appointment.php">Cancelled Appointment</a></li>
         <li><a class="dropdown-item" href="all_appointments.php">All Appointment</a></li>
         <li><a class="dropdown-item" href="admin_search.php">Search Appointment</a></li>
         <li><a class="dropdown-item" href="admin_report.php">Report</a></li>
         
         
      </ul>
      

      <button class="btn btn-primary dropdown-toggle navbar-brand text-white h2" type="button" id="dropdownMenuButton1" data-bs-toggle="dropdown" aria-expanded="false"
        ><img src="images/sg.png" alt="" width="23px" height="23px"> <?php echo $_SESSION['email'];?></button>
       

        <ul class="dropdown-menu" aria-labelledby="dropdownMenuButton1">
      <li><a class="dropdown-item" href="admin_change_password.php"><img src="images/settings.png" alt="" width="20px" height="20px">  Change password</a></li>
         <li><a class="dropdown-item" href="logout.php"><img src="images/sign.png" alt="" width="25px" height="25px"> Logout</a></li>
    
</div>



</div>
  </div> 

   <div class="bg-white shadow-sm ">
       <div class="container pb-2 pt-"> 
           <div class="row">
               <nav class="nav nav-underline">
              
                   <div class="nav-link">Appointment / View</div>
               </nav>
           </div>

       </div>
  </div>

  

  <div class="container mt-5">
      <div class="row">

          <div class="col-md-12">
 
          </div>
          <!-- <div class="col-md-12 text-right">
              <a class="btn btn-primary" href="">Add User</a>
          </div>
      </div> -->
  </div>

   
<div class="row">

<div style="width:306px;" class="col-md-6 mb-4">
    <div class="card border-left-success shadow h-100 py-2" style="background-color:#26c6da; color:white;">

    <?php
    $doctors="SELECT * FROM doctors";
    $doctorresult=mysqli_query($con,$doctors);
    $doctorrow=mysqli_num_rows($doctorresult);

    $patients="SELECT * FROM patients";
    $patientresult=mysqli_query($con,$patients);
    $patientrow=mysqli_num_rows($patientresult);

    $appointment="SELECT * FROM `appointments` where `status`='approved'";
    $approvedresult=mysqli_query($con,$appointment);
    $approvedrow=mysqli_num_rows($approvedresult);

    $appointments="SELECT * FROM `appointments` where `status`='not approved'";
    $noapprovedresult=mysqli_query($con,$appointments);
    $noapprovedrow=mysqli_num_rows($noapprovedresult);

    ?>

        <div class="card-body">
            <div class="row no-gutters align-items-center">
                <div class="col mr-2">
                    <div class="text-xs font-weight-bold text-uppercase mb-1" style="color:white;">ALL DOCTORS</div>
                    <div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $doctorrow ?></div>
                </div>
                <div class="col-auto">
                    class="fas fa-dollar-sign fa-2x text-gray-300" style="background-color: rgba(102, 187, 106, 1); color: rgba(255, 255, 255, 1)">
                </div>
            </div>
        </div>
    </div>
</div>

<div class="col-xl-3 col-md-6 mb-4">
    <div class="card border-left-success shadow h-100 py-2" style="background-color:#ef5350; color:white;">
        <div class="card-body">
            <div class="row no-gutters align-items-center">
                <div class="col mr-2">
                    <div style="color:white;" class="text-xs font-weight-bold  text-uppercase mb-1">Cancelled appointments</div>

                    <div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $noapprovedrow ?></div>
                </div>
                <div class="col-auto">
                    ^__i class="fas fa-dollar-sign fa-2x text-gray-300">
                </div>
            </div>
        </div>
    </div>
</div>

<div class="col-xl-3 col-md-6 mb-4">
    <div class="card border-left-success shadow h-100 py-2" style="background-color:#007bff; color:white;">
        <div class="card-body">
            <div class="row no-gutters align-items-center">
                <div class="col mr-2">
                    <div style="color:white;" class="text-xs font-weight-bold  text-uppercase mb-1">APPROVED APPOINTMENTS</div>

                    <div class="h5 mb-0 font-weight-bold text-gray-800"><?php echo $approvedrow ?></div>
                </div>
                <div class="col-auto">
                    ^__i class="fas fa-dollar-sign fa-2x text-gray-300">
                </div>
            </div>
        </div>
    </div>
</div>

<div class="row">

  <div class="app-main">
      <div class="row">
         <div class="col-md-12">
         <div class="card">
              <div class="card-header bg-blue text-white text-center">
                  <div class="card-header-title"> Appointments</div>
                  
              </div>
              <div class="card-body">
                  <table class="table table-striped" style="text-align:center;">

                  
                      <tr>
                          <th>No</th>
                          <th>Patient Name</th>
                          <th>Doctor Name</th>
                          <th>Appointment Date </th>
                          <th>Appointment Time </th>
                          <th>Message</th>
                          <th>Remark</th>
                          <th>Status</th>
                          <th width="150">Action</th>
                      </tr>

                    <?php
                    $no=1;
                   while ($row=mysqli_fetch_assoc($result)){
                  ?>

                  <tr>
                  <td><?php echo $no++; ?></td>
                  <td><?php echo $row['fname']?></td>
                  <td><?php echo $row['lname']?></td>
                  <td><?php echo $row['appointment_date']?></td>
                  <td><?php echo $row['appointment_time']?></td>
                  <td><?php echo $row['message']?></td>
                  <td><?php echo $row['remark']?></td>
                  <td><?php echo $row['status']?></td>

                      <!-- <td>
                             
                          <a class="btn btn-primary btn-sm" href="update.php?id=<?php echo $row['id']?>">Update</a>
                          <a class="btn btn-danger btn-sm" href="delete.php?id=<?php echo $row['id']?>">Delete</a>
                         
                      </td> -->
                  </tr>
                  <?php } ?>
                  </table>
              </div>
         </div>
          </div>
      </div>
  </div>

  

  <script src="https://cdn.jsdelivr.net/npm/@popperjs/core@2.9.2/dist/umd/popper.min.js" integrity="sha384-IQsoLXl5PILFhosVNubq5LC7Qb9DXgDA9i+tQ8Zj3iwWAwPtgFTxbJ8NT4GN1R8p" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.min.js" integrity="sha384-cVKIPhGWiC2Al4u+LWgxfKTRIcfu0JTxR+EQDz/bgldoEyl4H0zUF0QKbrJ0EcQF" crossorigin="anonymous"></script>
<!-- <script src="assets/js/bootstrap.bundle.min.js"></script> -->


 class="fas fa-phone" style="color: rgba(0, 0, 255, 1)">
</body>
</html>


What I have tried:

i tried to fix it but i failed
Posted
Updated 15-Jun-23 9:21am

1 solution

Check your query:
$query=" SELECT `fname`,`lname`,`appointment_date`,`appointment_time`,`message`,`remark`,`status` FROM `appointments` INNER JOIN `patients` ON appointments.patientid= patients.id INNER JOIN doctors ON appointments.doctor_id=doctors.id";
At a guess (and without your DB that's all it can be) you need to explicitly reference the table that the filed is coming from: MySQL Joins[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900