How to submit data in multiple combobox

I am developing student attendance system… I got stuck in the following code… can anyone please help me how to submit multiple values in database

	$query="SELECT * FROM stud_info where stream='$st' and sec='$se' and class='$c' ORDER BY name ASC";
		echo '<table border="1" align="center" cellspacing="2" cellpadding="2">';
		echo	'<caption><font color="blue"><strong>Students of '.$st." Class:".$c." Sec:".$se;'</strong></font></caption>';
		echo'		<tr>
					<td align="left"><b>Roll Number</b></td>
					<td align="left"><b>Name</b></td>
			echo "<tr>
					<td align=\\"left\\">$i</td>
					<td align=\\"left\\">$row[1]</td>
					<td align=\\"left\\"> 
						<select name='ps'>

echo ‘<tr colspan=“3” align=“center”>
<td> <input type=“submit” name=“record” value=“Submit Attendence”/></td>
echo ‘</table>’;


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.

  1. Make name=“ps” to read as name=“ps[$row[0]]” (I am assuming row[0] is the student id in the table)
  2. 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

  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";

You need to enclose your form elemets into <form> tag!
Give them name, like you entered in your <select name=“ps”> tag, example:

  <form action="yoursubmitfile.php" method="post">
    <select name='ps'>
    <input type="submit" name="record" value="Submit Attendence"/>

and process your data in the yoursubmitfile.php

if(isset($_POST)) {
  $ps = $_POST['ps']; // info about attendance
  $query = "insert into [tablename] (id, ps) values ([id], $ps)";
  // process query into database etc.

Thanks cpradio … I will try to implement and ask you guys if any problem…