<?php
include("connect.php");
error_reporting(0);
?>
<html>
<?php
if(!isset($_SESSION['userid'])){
header("Location:index.php");
}else{
$result = mysql_query("select * from users_info where userid='".$_SESSION['userid']."'");
while($row = mysql_fetch_array($result)){
echo "Welcome"." ".$row['first_name']."";
}
?>
<a href="logout.php">Log out</a>   <a href="adminpage.php">Back</a>
<br/>
<hr/>
<head></head>
<body>
<div style="float:left;border:1px solid black;overflow:auto;">
<a style="text-decoration:none;" href="adminchat.php">Join the Group Chat</a><br/>
<a style="text-decoration:none;"href="make_record.php">Add/Make a Account</a><br/>
<a style="text-decoration:none;"href="appoint.php">Appoint an admin</a><br/>
<a style="text-decoration:none;"href="user_check.php">Check users information</a><br/>
<a style="text-decoration:none;"href="check_appointment.php">Check Appointments</a><br/>
</div>
<div style="overflow:auto;">
<?php
echo "<table border=\"1\">";
echo "<tr><td>User ID</td><td>First Name</td><td>Last Name</td><td>Date</td><td>Tooth number</td> <td>Procedure</td><td>Dentist</td><td>Amount Charged</td><td>Amount Paid</td><td>Balance</td></tr>";
$query = mysql_query("SELECT * FROM users_treatment_record ORDER BY record_id") or die(mysql_error());
for($i = 0; $i < mysql_num_rows($query); $i++)
{
$a = mysql_result($query, $i, 'user_id');
$fname= mysql_result($query,$i,'first_name');
$lname= mysql_result($query,$i,'last_name');
$b = mysql_result($query, $i, 'date');
$c = mysql_result($query, $i, 'tooth_num');
$d = mysql_result($query, $i, 'procedure');
$e = mysql_result($query, $i, 'dentist');
$f = mysql_result($query, $i, 'amount_charged');
$g = mysql_result($query, $i, 'amount_paid');
$h = mysql_result($query, $i, 'balance');
echo '<tr><td>'.$a.'</td><td>'.$fname.'</td><td>'.$lname.'</td><td>'.$b.'</td><td>'.$c.'</td> <td>'.$d.'</td><td>'.$e.'</td><td>'.$f.'</td><td>'.$g.'</td><td>'.$h.'</td><td><a href="edit_record.php?action=edit&id='.$a.'">edit</a></td>';
}
echo "</table>";
if(isset($_GET["action"]) && $_GET["action"] == "edit" && $_GET["id"]){
$id=$_GET["id"];
$query = mysql_query("SELECT * FROM users_treatment_record WHERE user_id='$id'") or die(mysql_error());
echo "<div style=\"position:absolute;top:0;right:180;z-index:1;background-color:FFFFFF;border:1px solid black;\">";
echo "Edit<br/><br/>";
$a = mysql_result($query, 0, 'user_id');
$fname = mysql_result($query, 0, 'first_name');
$lname = mysql_result($query, 0, 'last_name');
$b = mysql_result($query, 0, 'date');
$c = mysql_result($query, 0, 'tooth_num');
$d = mysql_result($query, 0, 'procedure');
$e = mysql_result($query, 0, 'dentist');
$f = mysql_result($query, 0, 'amount_charged');
$g = mysql_result($query, 0, 'amount_paid');
$h = mysql_result($query, 0, 'balance');
echo "<form method='post' action='edit_record.php'>";
echo "user id: <input type='text' disabled='disabled' name='aa' value='$a'><br/>";
echo "<input type='hidden' name='a' value='$a'><br/>";
echo "date: <input type='text' disabled='disabled' name='bb' value='$b'><br/>";
echo "<input type='hidden' name='b' value='$b'><br/>";
echo "tooth number: <input type='text' name='c' value='$c'><br/>";
echo "procedure: <input type='text' name='d' value='$d'><br/>";
echo "dentist: <input type='text' name='e' value='$e'><br/>";
echo "amount charged: <input type='text' name='f' value='$f'><br/>";
echo "amount paid: <input type='text' name='g' value='$g'><br/>";
echo "balance: <input type='text' name='h' value='$h'><br/>";
echo "<input type='submit' value='edit' name='editor' />";
echo "<a href='edit_record.php'>back</a>";
echo "</form>";
echo "</div>";
}
if(isset($_POST['editor'])){
$id=$_POST['a']+1;
$b=$_POST['b'];
$c=$_POST['c'];
$d=$_POST['d'];
$e=$_POST['e'];
$f=$_POST['f'];
$g=$_POST['g'];
$h=$_POST['h'];
mysql_query("UPDATE users_treatment_record SET `procedure` = '$d',dentist= '$e' , amount_charged= '$f' , tooth_num = '$c',amount_paid= '$g' , balance= '$h' WHERE user_id = '".$id."'")or die(mysql_error());
echo '<meta http-equiv="refresh" content="0;url=edit_record.php">';
exit;
}
}
?>
</div>
</body>
</html>
First please do disregard the aligning of my code
about my problem:
the update fails after i update the form >_>
any help would be appreciated..

New Topic/Question
Reply




MultiQuote





|