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

$pid = $_SESSION['patient_id'];

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

<h2>My Prescriptions</h2>

<table border="1">
<tr>
<th>Date</th>
<th>Diagnosis</th>
<th>View</th>
</tr>

<?php while($row=mysqli_fetch_assoc($r)){ ?>
<tr>
<td><?php echo $row['created_at']; ?></td>
<td><?php echo $row['diagnosis']; ?></td>
<td>
<a href="print_prescription.php?id=<?php echo $row['id']; ?>">Open</a>
</td>
</tr>
<?php } ?>

</table>