show data in data tables in ajax respose in php

<?php
include_once('config.php');
session_start();
if (!isset($_SESSION['email'])) {
    header('Location: admin-login.php');
    exit;
  }

  $selected_date=$_POST['selected_date'];
  $sql="SELECT * FROM  `appointment` where appoinment_date='".$selected_date."'  ORDER BY appointment_id DESC";
  $result=mysql_query($sql);
  $number_of_rows = mysql_num_rows($result);
  $msg='';
  $msg.='<center>';
  $msg.='<strong>';
  $msg.='Selected Date:&nbsp;&nbsp;';
  $msg.='</strong>';
  $msg.='<strong>';
  $msg.=$_POST['selected_date'];
  $msg.='</strong>';
  $msg.='</center>';
 
 $msg.='<table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
                                <thead>
                                    <tr>
                                        <th>Patient Name</th>
                                        <th>Patient Number</th>
                                        <th>Patient Age</th>
                                        <th>Gender</th>
                                        <th>Health Issue</th>
                                        <th>Appoinment Date</th>
                                        <th>Appoinment Time</th>
                                         <th>Appointment Status</th>
                                     
                                    </tr>
                                </thead>
                                <tbody>';
  if($number_of_rows > 0)
  {
    
     while($row=mysql_fetch_array($result))
     {
    $msg.='<tr class="odd gradeX">';
    $msg.='<td>';
    $msg.=$row['patient_name'];
    $msg.='</td>';
    $msg.='<td>';
    $msg.=$row['patient_number'];
    $msg.='</td>';
    $msg.='<td>';
    $msg.=$row['patient_age'];
    $msg.='</td>';
    $msg.='<td>';
    $msg.=$row['gender'];
    $msg.='</td>';
    $msg.='<td>';
    $msg.=$row['health_issue'];
    $msg.='</td>';
    $msg.='<td>';
    $msg.=$row['appoinment_date'];
    $msg.='</td>';
    $msg.='<td>';
    $msg.=$row['appoinment_time'];
    $msg.='</td>';
    $msg.='<td>';
    $msg.='<select name="appoinment_status" class="form-control" onchange="admin_appoinment_status( '.$row['appointment_id'].' , '.$row['patient_id'].')">';
     $selected = $row['status'];
         $options  = array('Pending', 'Approved', 'Rejected');
   
    foreach($options  as $option_key => $option_value)
                 {
                    if($selected == $option_key){
                    $msg.='<option selected="selected" value='.$option_key.'>'.$option_value.'</option>';
                    }else{
                          $msg.='<option value='.$option_key.'>'.$option_value.'</option>';
                    }
               
                 }
   
   
    $msg.='</select>';
    $msg.='</td>';
    $msg.='</tr>';
   
   
   
   
     }
  }
  else
  {
   $msg='No Appoinment On This Date: '.$_POST['selected_date'].'';
  }
 
  $msg.='</tbody></table>';
echo $msg;
  
?>

Comments

Popular posts from this blog

dynamic create multiple ckeditor onclick event using jquery

get lat and long from city name using jquery

membership registration and login system in php