Jump to content

php + mysql


dreamz

Recommended Posts

Hey,,getting an error when i run this. any help appreciated :D

<?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');

?>

 

I get the following error:

 

Parse error: parse error, unexpected T_VARIABLE in c:\webs\test\view_appointment.php on line 24

 

Any help appreciated!!

Link to comment
Share on other sites

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;

 

Missing a ";"

 

try

 

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;

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.