hi
i have here a form which a result query from database. i would like to execute a script which insert to another table, those data with a check can only be inserted. my problem is that when i check the first 2, skip two data, and check the last data, i get the first 3 data. still the same when i check the 1st, skip 2nd,3rd,4th, check the last, i still get the first 2 data which is wrong. hope i make it clear.
here is the form
<form method='POST' action='add.php'>
<table border='0' width='100%' class='kylin'>
<tr>
<th width='6%'>Add</td>
</tr>
<tr>
<td> <input type='text' readonly value='LSO13' name='xsocode[]'></td>
<td width='3%'><input type='checkbox' name='check_block[]' value='check_block' checked></td>
</tr>
<tr>
<td> <input type='text' readonly value='LSO15' name='xsocode[]'></td>
<td width='3%'><input type='checkbox' name='check_block[]' value='check_block' checked></td>
</tr>
<tr>
<td> <input type='text' readonly value='LSO17' name='xsocode[]'></td>
<td width='3%'><input type='checkbox' name='check_block[]' value='check_block' checked></td>
</tr>
<tr>
<td> <input type='text' readonly value='LSO71' name='xsocode[]'></td>
<td width='3%'><input type='checkbox' name='check_block[]' value='check_block' checked></td>
</tr>
<tr>
<td> <input type='text' readonly value='LSO16' name='xsocode[]'></td>
<td width='3%'><input type='checkbox' name='check_block[]' value='check_block' checked></td>
</tr>
</table>
<input type='submit' value='Submit' name='submit'>
<input type='hidden' value='set'name='pasalog' />
<input type='hidden' value='04-05607' name='xstudentno'>
<input type='hidden' value='vincent' name='user'>
</p>
</form>
here is my code for add.php
$vsocode = $_POST['xsocode'];
$vstudentno = $_POST['xstudentno'];
$vuser = $_POST['user'];
$vdate = date('m-d-Y');
$vtime = date('h:i:s A');
$kylin = $_POST['check_block'];
if (isset($_POST['pasalog'])) {
foreach ($kylin as $key => $value) {
$query = "
INSERT INTO subjects_enrolled_tbl SET studentno = '$vstudentno', subjectenrolled = '$vsocode[$key]', encoder = '$vuser', dateentered = '$vdate', timeentered = '$vtime';
";
print $key . "-" . $query . "<br/>";
}
}