I just cannot figure this out. Let's say I have an appointment tool to schedule appointments. For every appointment I have an additonal form that shows certain information specific to only that appointment.
Now when a user clicks a button called form it takes them to an additional page on this additional page I want to show another list of appointments but only that have the same name as the one that was clicked on.
In the appointments table in the database the names are stored in lep. The first php code I have provided gets the name for only the selected appointment. The second code provided get's all the appointments. I have attached some screenshots that hopefully prove helpful.
How can I get only the appointments where the lep is the same as the lep that comes from the first code?
<?php
require "id.php";
require "calendarconnect.php";
//MySqli Select Query
$query = $mysqli->query("SELECT lep FROM appointments WHERE ID = $contactid");
while ($line = mysqli_fetch_array($query, MYSQL_ASSOC)) {
echo $line['lep'];}
require "freeclose.php";
?>
<?php
require "calendarconnect.php";
//MySqli Select Query
$query = $mysqli->query("SELECT ID, appointmentdate, appointmenttime, nature, doctorname, lep FROM appointments ORDER BY appointmentdate");
print '<table cellpadding="10" cellspacing="3" border="1" class="sortable">';
print '<tr><th>Date/Time</th><th>Nature</th><th>Doctor Name</th><th>Actions</th></tr>';
while($row = $query->fetch_assoc()) {
print '<tr>';
print "<td>" . date("m-d-y", strtotime($row['appointmentdate'])) . " " .date( "g:i A",strtotime($row['appointmenttime'] )). "</td>";
print '<td>'.$row["nature"].'</td>';
print '<td>'.$row["doctorname"].'</td>';
print "<td><a href=\"index.php?option=com_content&view=article&id=18&cd=" . $row['ID'] . "\">Edit | </a>";
print "<a href=\"appointmentdelete.php?id=" . $row['ID'] . "\"onclick=
\"return confirm('Are you sure you want to delete?')\">Delete</a></td>";
print '</tr>';
}
print '</table>';
require "freeclose.php";
?>