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
https://forums.phpfreaks.com/topic/90565-php-mysql/
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
https://forums.phpfreaks.com/topic/90565-php-mysql/#findComment-464335
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.