Okay, from what I gather, you are trying to create a list of students, with a drop down next to each student name that contains “Present” or “Absent”, correct?
Then you want to post that data back to either this page or another page so the instructor can quickly update the status of all students?
With those assumptions there are two things you need to your existing code before you can read any posted data.
Make name=“ps” to read as name=“ps[$row[0]]” (I am assuming row[0] is the student id in the table)
Add a value to each <option> tag, ex: <option value=“Present”>Present</option> (although the browser may do that automatically)
Now when you submit your form, you will have an array in your $_POST variable for ‘ps’.
You will want to use a foreach loop to read the array, so you can grab the student id from the key, and the Present/Absent from the value.
Your code will be similar to the following
<?php
if (isset($_POST['record']))
{
if (isset($_POST['ps']) && is_array($_POST['ps']))
{
foreach ($_POST['ps'] as $key => $value)
{
$studentId = intval($key);
$studentPresence = ($value === 'Absent') ? 'Absent' : 'Present';
$query="UPDATE <TABLE> SET <PRESENCE COLUMN> = '$studentPresence' WHERE <STUDENT_ID_COLUMN> = $studentId";
$result=@mysql_query($query);
}
}
}
?>
if(isset($_POST)) {
$ps = $_POST['ps']; // info about attendance
$query = "insert into [tablename] (id, ps) values ([id], $ps)";
// process query into database etc.
}