Author Topic: PHP and mySQL  (Read 1116 times)

dreamer

  • New Member
  • *
  • Posts: 1
  • Karma: +0/-0
    • View Profile
PHP and mySQL
« on: February 11, 2008, 03:15:45 PM »
Hey, I'm having a bit of trouble with this code........
Code: [Select]
<?php
#view_appointment&#46;php
session_start();

if(
$_SESSION['access_level'&#93; == 1)
{
 
#require_once('&#46;/connections/connect&#46;php');
 #require_once('&#46;/templates/header&#46;php');
 
$query "SELECT * FROM appointment";
 
$result mysql_query($query);
 
 echo 
'<p><a href="view_appointment&#46;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'&#93;;
 $adate $row['a_date'&#93;;
 $pid $row['p_id'&#93;;
 $diagnosis $row['diagnosis'&#93;;
 $fee $row['fee'&#93;
 $_SESSION['a_id'&#93; = $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&#46;php" name"delete_appointment"><input type = "submit" name = "submit" id = "submit" value = "Delete Appointment"/><input type = "hidden" name = "a_id" value = "'&#46;$aid&#46; '"/></form></td><td><form method = "post" action = "edit_appointment&#46;php" name = "edit_appointment"><input type = "submit" name = "submit" id = "submit" value = "Edit Appointment" /><input type = "hidden" name = "id" value = "'&#46;$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'&#93;))
{
 
$view $_POST['view'&#93;;
 
switch($view)
 {
  case 
'a_id'&#58;
$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&#58; '&#46;$num_results&#46;'</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>'&#46;$row['a_id'&#93;&#46;'</p></td>';
 echo '<td><p>'&#46;$row['a_date'&#93;&#46;'</p></td>';
 echo '<td><p>'&#46;$row['p_id'&#93;&#46;'</p></td>;
 echo '<td><p>'&#46;$row['diagnosis'&#93;&#46;'</p></td>;
         
echo '<td><p>'&#46;$row['fee'&#93;&#46;'</p></td>;
 echo '<tr>';
}

echo '</table>';
break;

case 'a_date'&#58;
$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&#58; '&#46;$num_results&#46;'</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>'&#46;$row['a_id'&#93;&#46;'</p></td>';
 echo '<td><p>'&#46;$row['a_date'&#93;&#46;'</p></td>';
 echo '<td><p>'&#46;$row['p_id'&#93;&#46;'</p></td>;
 echo '<td><p>'&#46;$row['diagnosis'&#93;&#46;'</p></td>;
         
echo '<td><p>'&#46;$row['fee'&#93;&#46;'</p></td>;
 echo '<tr>';
}

echo '</table>';
break;

case 'p_id'&#58;
$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&#58; '&#46;$num_results&#46;'</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>'&#46;$row['a_id'&#93;&#46;'</p></td>';
 echo '<td><p>'&#46;$row['a_date'&#93;&#46;'</p></td>';
 echo '<td><p>'&#46;$row['p_id'&#93;&#46;'</p></td>;
 echo '<td><p>'&#46;$row['diagnosis'&#93;&#46;'</p></td>;
         
echo '<td><p>'&#46;$row['fee'&#93;&#46;'</p></td>;
 echo '<tr>';
}

echo '</table>';
break;

case 'diagnosis'&#58;
$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&#58; '&#46;$num_results&#46;'</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>'&#46;$row['a_id'&#93;&#46;'</p></td>';
 echo '<td><p>'&#46;$row['a_date'&#93;&#46;'</p></td>';
 echo '<td><p>'&#46;$row['p_id'&#93;&#46;'</p></td>;
 echo '<td><p>'&#46;$row['diagnosis'&#93;&#46;'</p></td>;
         
echo '<td><p>'&#46;$row['fee'&#93;&#46;'</p></td>;
 echo '<tr>';
}

echo '</table>';
break;

case 'fee'&#58;
$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&#58; '&#46;$num_results&#46;'</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>'&#46;$row['a_id'&#93;&#46;'</p></td>';
 echo '<td><p>'&#46;$row['a_date'&#93;&#46;'</p></td>';
 echo '<td><p>'&#46;$row['p_id'&#93;&#46;'</p></td>;
 echo '<td><p>'&#46;$row['diagnosis'&#93;&#46;'</p></td>;
         
echo '<td><p>'&#46;$row['fee'&#93;&#46;'</p></td>;
 echo '<tr>';
}

echo '</table>';
break;

}

}

if (isset(
$_POST['search'&#93;))
{
 
$find $_POST['find'&#93;;
 
$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&#58; '&#46;$num_results&#46;'</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>'&#46;$row['a_id'&#93;&#46;'</p></td>';
 echo '<td><p>'&#46;$row['a_date'&#93;&#46;'</p></td>';
 echo '<td><p>'&#46;$row['p_id'&#93;&#46;'</p></td>;
 echo '<td><p>'&#46;$row['diagnosis'&#93;&#46;'</p></td>;
         
echo '<td><p>'&#46;$row['fee'&#93;&#46;'</p></td>;
 echo '<tr>';
 }
 
 echo 
'</table>';
 
}

#require_once ('&#46;/templates/footer&#46;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!!!  :D

Zyppora

  • Global Moderator
  • Senior Member
  • *****
  • Posts: 1401
  • Karma: +0/-0
    • View Profile
Re: PHP and mySQL
« Reply #1 on: February 12, 2008, 06:42:54 AM »
Which line is line 24?
HAVE YOU TRIED DEBUGGING? Example code in this reply deliberately contains BUGS. PHP forum for beginners.