<?php
session_start();
include "config.php";

$pid = $_SESSION['patient_id'];

$r = mysqli_query($conn,
"SELECT * FROM appointments WHERE patient_id='$pid' ORDER BY id DESC");
?>

<h2>My Appointments</h2>

<table border="1">
<tr>
<th>Date</th>
<th>Time</th>
<th>Reason</th>
</tr>

<?php while($row=mysqli_fetch_assoc($r)){ ?>
<tr>
<td><?php echo $row['visit_date']; ?></td>
<td><?php echo $row['visit_time']; ?></td>
<td><?php echo $row['reason']; ?></td>
</tr>
<?php } ?>

</table>