Hey, I'm having a bit of trouble with this code........
<?php
#view_appointment.php
session_start();
if($_SESSION['access_level'] == 1)
{
#require_once('./connections/connect.php');
#require_once('./templates/header.php');
$query = "SELECT * FROM appointment";
$result = mysql_query($query);
echo '<p><a href="view_appointment.php">View Appointments</a></p>';
echo "<p></p>";
echo "<table class='appointment'>";
echo "<th>Appointment ID</th><th>Appointment Date</th><th>Patient ID</th><th>Diagnosis</th><th>Fee</th><th></th><th></th>";
while ($row = mysql_fetch_array($result))
{
$aid = $row['a_id'];
$adate = $row['a_date'];
$pid = $row['p_id'];
$diagnosis = $row['diagnosis'];
$fee = $row['fee']
$_SESSION['a_id'] = $a_id;
echo "<tr><td>$a_id</td><td>$a_date</td><td>$p_id</td><td>$diagnosis</td><td>$fee</td>";
echo '<td><form method="post" action="delete_appointment.php" name"delete_appointment"><input type = "submit" name = "submit" id = "submit" value = "Delete Appointment"/><input type = "hidden" name = "a_id" value = "'.$aid. '"/></form></td><td><form method = "post" action = "edit_appointment.php" name = "edit_appointment"><input type = "submit" name = "submit" id = "submit" value = "Edit Appointment" /><input type = "hidden" name = "id" value = "'.$aid'" /></form></td></tr>';
}
echo "</table>";
}
?>
<p>Select an option to refine your search</p>
<form method = "post" action = "view_appointment.php">
<p>View Appointment By:</p>
<select name = "view">
<option value = "a_id">Appointment ID
<option value = "a_date">Appointment Date
<option value = "diagnosis">Diagnosis
<option value = "fee">Fee
</select>
<input type = "submit" name = "submit" id = "submit" value = "Go">
<p>Enter Appointment ID :</p>
<input type = "text" name = "find">
<input type = "submit" name = "search" id = "search" value = "Go"</p>
</form>
<?php
if (isset($_POST['submit']))
{
$view = $_POST['view'];
switch($view)
{
case 'a_id':
$query = "SELECT a_id, a_date, diagnosis, fee, p_id FROM appointment ORDER BY a_id";
$result = mysql_query($query) or die(mysql_error());
$num_results = mysql_num_rows($result);
echo '<p>Number of records found: '.$num_results.'</p>';
echo '<table class="appointment">';
echo '<th>Appointment ID</th><th>Appointment Date</th><th>Patient ID</th><th>Diagnosis</th><th>Fee</th></tr>';
while ($row = mysql_fetch_array($result))
{
echo '<tr>';
echo '<td><p>'.$row['a_id'].'</p></td>';
echo '<td><p>'.$row['a_date'].'</p></td>';
echo '<td><p>'.$row['p_id'].'</p></td>;
echo '<td><p>'.$row['diagnosis'].'</p></td>;
echo '<td><p>'.$row['fee'].'</p></td>;
echo '<tr>';
}
echo '</table>';
break;
case 'a_date':
$query = "SELECT a_id, a_date, diagnosis, fee, p_id FROM appointment ORDER BY a_date";
$result = mysql_query($query) or die(mysql_error());
$num_results = mysql_num_rows($result);
echo '<p>Number of records found: '.$num_results.'</p>';
echo '<table class="appointment">';
echo '<th>Appointment ID</th><th>Appointment Date</th><th>Patient ID</th><th>Diagnosis</th><th>Fee</th></tr>';
while ($row = mysql_fetch_array($result))
{
echo '<tr>';
echo '<td><p>'.$row['a_id'].'</p></td>';
echo '<td><p>'.$row['a_date'].'</p></td>';
echo '<td><p>'.$row['p_id'].'</p></td>;
echo '<td><p>'.$row['diagnosis'].'</p></td>;
echo '<td><p>'.$row['fee'].'</p></td>;
echo '<tr>';
}
echo '</table>';
break;
case 'p_id':
$query = "SELECT a_id, a_date, diagnosis, fee, p_id FROM appointment ORDER BY p_id";
$result = mysql_query($query) or die(mysql_error());
$num_results = mysql_num_rows($result);
echo '<p>Number of records found: '.$num_results.'</p>';
echo '<table class="appointment">';
echo '<th>Appointment ID</th><th>Appointment Date</th><th>Patient ID</th><th>Diagnosis</th><th>Fee</th></tr>';
while ($row = mysql_fetch_array($result))
{
echo '<tr>';
echo '<td><p>'.$row['a_id'].'</p></td>';
echo '<td><p>'.$row['a_date'].'</p></td>';
echo '<td><p>'.$row['p_id'].'</p></td>;
echo '<td><p>'.$row['diagnosis'].'</p></td>;
echo '<td><p>'.$row['fee'].'</p></td>;
echo '<tr>';
}
echo '</table>';
break;
case 'diagnosis':
$query = "SELECT a_id, a_date, diagnosis, fee, p_id FROM appointment ORDER BY diagnosis";
$result = mysql_query($query) or die(mysql_error());
$num_results = mysql_num_rows($result);
echo '<p>Number of records found: '.$num_results.'</p>';
echo '<table class="appointment">';
echo '<th>Appointment ID</th><th>Appointment Date</th><th>Patient ID</th><th>Diagnosis</th><th>Fee</th></tr>';
while ($row = mysql_fetch_array($result))
{
echo '<tr>';
echo '<td><p>'.$row['a_id'].'</p></td>';
echo '<td><p>'.$row['a_date'].'</p></td>';
echo '<td><p>'.$row['p_id'].'</p></td>;
echo '<td><p>'.$row['diagnosis'].'</p></td>;
echo '<td><p>'.$row['fee'].'</p></td>;
echo '<tr>';
}
echo '</table>';
break;
case 'fee':
$query = "SELECT a_id, a_date, diagnosis, fee, p_id FROM appointment ORDER BY fee";
$result = mysql_query($query) or die(mysql_error());
$num_results = mysql_num_rows($result);
echo '<p>Number of records found: '.$num_results.'</p>';
echo '<table class="appointment">';
echo '<th>Appointment ID</th><th>Appointment Date</th><th>Patient ID</th><th>Diagnosis</th><th>Fee</th></tr>';
while ($row = mysql_fetch_array($result))
{
echo '<tr>';
echo '<td><p>'.$row['a_id'].'</p></td>';
echo '<td><p>'.$row['a_date'].'</p></td>';
echo '<td><p>'.$row['p_id'].'</p></td>;
echo '<td><p>'.$row['diagnosis'].'</p></td>;
echo '<td><p>'.$row['fee'].'</p></td>;
echo '<tr>';
}
echo '</table>';
break;
}
}
if (isset($_POST['search']))
{
$find = $_POST['find'];
$query = "SELECT * FROM appointment WHERE a_id = '$find'";
$result = mysql_query($query) or die(mysql_error());
$num_results = mysql_num_rows($result);
echo '<p>Number of records found: '.$num_results.'</p>';
echo '<table class = "appointment">';
echo '<th>Appointment ID</th><th>Appointment Date</th><th>Patient ID</th><th>Diagnosis</th><th>Fee</th></tr>';
while ($row = mysql_fetch_array($result))
{
echo '<tr>';
echo '<td><p>'.$row['a_id'].'</p></td>';
echo '<td><p>'.$row['a_date'].'</p></td>';
echo '<td><p>'.$row['p_id'].'</p></td>;
echo '<td><p>'.$row['diagnosis'].'</p></td>;
echo '<td><p>'.$row['fee'].'</p></td>;
echo '<tr>';
}
echo '</table>';
}
#require_once ('./templates/footer.php');
?>
When I try to run it, I receive the following error:
Parse error: parse error, unexpected T_VARIABLE in c:webstestview_appointment.php on line 24
Thanks, Any help appreciated!!!
