jeanmarat1793
05-05-2009, 04:07 PM
Here's what i basically want to do :
A user, in this case a teacher, by selecting an appropriate option to be able to update data concerning his students absencies reports.
Here's what my table for the students' absencies looks like (nevermind the greek)
http://i42.tinypic.com/ofwuhu.jpg
And here's what my browser shows up (yes thats in greek too but you'll get the idea):
http://i43.tinypic.com/553q5j.jpg
Here's my code :
if ($teacherclass=="e") // if teacher selects the EDIT option from a dropdown menu
{
include ("config.php"); // just plain connecting to the database
$con=mysql_connect($dbhost,$dbuser,$dbpass)
or die("Cannot connect to database");
mysql_select_db('dbusers');
mysql_query("set names utf8;"); //
echo "<br>Your class is :";
$myclass= $_SESSION['myclass']['class']; // That's a session started when the user logged in with his class.
echo $myclass; //e.g. B1
echo "<br>";
echo "<br>";
$query = "SELECT * FROM absencies WHERE class = '$myclass' " ; //shows all students that are in the same class as the teacher/user is
$result = mysql_query($query);
while ($row= mysql_fetch_array($result)){
echo "<table width=800 border=1 cellpading=1>
<tr>
<td><b>Real name:</b></td>
<td>".$row['realname']."</td>
</tr>
<tr>
<td> Unjustified absecnies of Year 1 , Semester 1 :</td>
<td>".$row['A1a']."</td>
<td>
<form action='absencies.php' method='POST' accept-charset='UTF-8'>
<input type='hidden' name='submitted' value=1>
<input type='text' name='A1a'>
<input type='submit' name='submit' value='Edit'></td>
</tr>
<tr>
<td>Justified absencies of Year 1, Semester 1 :</td>
<td>". $row['A1d']."</td>
<td><input type='text' name='A1d'><input type='submit' name='submit' value='Edit'></td>
</tr>
<tr>
<td>unjustified absencies of Year 1, semester 2:</td>
<td>".$row['A2a']."</td>
<td><input type='text' name='A2a'><input type='submit' name='submit' value='Edit'></td>
</tr>
<tr>
<td>Justified absencies of Year 1 , semester 2:</td>
<td>".$row['A2d']."</td>
<td><input type='text' name='A2d'><input type='submit' name='submit' value='Edit'></td>
</tr>
etc. for all semesters
...
</table>
if ($_POST['submitted']==1) {
// THIS WHERE I SHOULD enterMY queries *update" etc.
}
}
}
My problem IS HOW TO UPDATE the fields withouf UPDATING all of them but one at a time.
Ok I used the loop to show the students status however i dont want to get a loop updating every single student. But just the one i choose.
A user, in this case a teacher, by selecting an appropriate option to be able to update data concerning his students absencies reports.
Here's what my table for the students' absencies looks like (nevermind the greek)
http://i42.tinypic.com/ofwuhu.jpg
And here's what my browser shows up (yes thats in greek too but you'll get the idea):
http://i43.tinypic.com/553q5j.jpg
Here's my code :
if ($teacherclass=="e") // if teacher selects the EDIT option from a dropdown menu
{
include ("config.php"); // just plain connecting to the database
$con=mysql_connect($dbhost,$dbuser,$dbpass)
or die("Cannot connect to database");
mysql_select_db('dbusers');
mysql_query("set names utf8;"); //
echo "<br>Your class is :";
$myclass= $_SESSION['myclass']['class']; // That's a session started when the user logged in with his class.
echo $myclass; //e.g. B1
echo "<br>";
echo "<br>";
$query = "SELECT * FROM absencies WHERE class = '$myclass' " ; //shows all students that are in the same class as the teacher/user is
$result = mysql_query($query);
while ($row= mysql_fetch_array($result)){
echo "<table width=800 border=1 cellpading=1>
<tr>
<td><b>Real name:</b></td>
<td>".$row['realname']."</td>
</tr>
<tr>
<td> Unjustified absecnies of Year 1 , Semester 1 :</td>
<td>".$row['A1a']."</td>
<td>
<form action='absencies.php' method='POST' accept-charset='UTF-8'>
<input type='hidden' name='submitted' value=1>
<input type='text' name='A1a'>
<input type='submit' name='submit' value='Edit'></td>
</tr>
<tr>
<td>Justified absencies of Year 1, Semester 1 :</td>
<td>". $row['A1d']."</td>
<td><input type='text' name='A1d'><input type='submit' name='submit' value='Edit'></td>
</tr>
<tr>
<td>unjustified absencies of Year 1, semester 2:</td>
<td>".$row['A2a']."</td>
<td><input type='text' name='A2a'><input type='submit' name='submit' value='Edit'></td>
</tr>
<tr>
<td>Justified absencies of Year 1 , semester 2:</td>
<td>".$row['A2d']."</td>
<td><input type='text' name='A2d'><input type='submit' name='submit' value='Edit'></td>
</tr>
etc. for all semesters
...
</table>
if ($_POST['submitted']==1) {
// THIS WHERE I SHOULD enterMY queries *update" etc.
}
}
}
My problem IS HOW TO UPDATE the fields withouf UPDATING all of them but one at a time.
Ok I used the loop to show the students status however i dont want to get a loop updating every single student. But just the one i choose.