mercredi 16 octobre 2019

if condition inside table data that table assign to a variable

I wanted to get database values when live search as a table. The following script i have tried. Without if condition it works perfectly. but i want to add that if statement to show the current status to the user. when i execute this code it give an error syntax error, unexpected end of file in C:\xampp\htdocs\hospital\hms\admin\fetch.php on line 62

<?php
$connect = mysqli_connect("localhost", "root", "", "hms");
$output = '';
if(isset($_POST["query"]))
{
   $search = mysqli_real_escape_string($connect, $_POST["query"]);
   $query = "select doctors.doctorName as docname,appointment.patientName as pname,appointment.*  
   from appointment join doctors on doctors.id=appointment.doctorId where patientName LIKE '%".$search."%' order by appointment.appId desc ";
}
else
{
$query = "select doctors.doctorName as docname,appointment.patientName as pname,appointment.*  from appointment join doctors on doctors.id=appointment.doctorId order by appointment.appId desc ";
}
$result = mysqli_query($connect, $query);
if(mysqli_num_rows($result) > 0)
{
$output .= '<div class="table-responsive">
                <table class="table table bordered">
                    <tr>

                        <th class="hidden-xs">Doctor Name</th>
                        <th>Appoinment Number</th>
                        <th>Patient Name</th>
                        <th>Specialization</th>
                        <th>Consultancy Fee</th>
                        <th>Appointment Date / Time </th>
                        <th>Appointment Creation Date  </th>
                        <th>Current Status</th>
                        <th>Action</th>
                    </tr>';

while($row = mysqli_fetch_array($result))
{
    $output .= '
        <tr>
            <td>'.$row["docname"].'</td>
            <td>'.$row["appNumber"].'</td>
            <td>'.$row["pname"].'</td>
            <td>'.$row["doctorSpecialization"].'</td>
            <td>'.$row["consultancyFees"].'</td>
            <td>'.$row["appointmentDate"].' / '.$row["appointmentTime"].'</td>
            <td>'.$row["postingDate"].'</td>
            '?><td><?php

                if(($row['currentStatus']==1) && ($row['payment']=='notPaid'))  
                    {
                        echo "<b>Active<b> <input type='button' value='Not Paid' style='border-radius: 5px;border: 2px solid  #f44336;color: black;padding: 6px;'>" ;
                    }

            ?></td>
            <?php'
        </tr>
    ';
}
echo $output;
}
else
{
   echo 'Data Not Found';
}
?>

Thank you for you help

Aucun commentaire:

Enregistrer un commentaire