Hi i'm unable to do multiple update (using Ms Acess because of restrictions). I try to do through ADO method (also because of restriction , x ODBC). The operation will break when reaching the script to update on the second page. Can you guys point where did i went wrong?
1st page:
<?php
$db_conn = new COM("ADODB.Connection");
$connstr = "DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=". realpath("./dbExam.mdb").";";
$db_conn->open($connstr);
$rS = $db_conn->execute("SELECT * from BC101");
$f1 = $rS->Fields(0);
$f2 = $rS->Fields(1);
$f3 = $rS->Fields(2);
$f4 = $rS->Fields(3);
$f5 = $rS->Fields(4);
$f6 = $rS->Fields(5);
$f7 = $rS->Fields(6);
$f8 = $rS->Fields(7);
$f9 = $rS->Fields(8);
?>
</br>
<?php
while (!$rS->EOF)
{ ?>
<tr>
<td align="center"><input name="id[]" type="hidden" type="text" id="id" value="<?php print $f1->value; ?>"><?php $id[] = $f1->value;?> <?php echo $f1->value;?></td>
<td align="center"><input name="NoPendaftaran[]" type="text" STYLE="color: #FFFFFF; font-family: Arial; font-size: 12px; background-color: #72A4D2;" size="15" maxlength="30" id="NoPendaftaran" value="<?php print $f2->value; ; ?>"></td>
<td align="center"><input name="S1[]" type="text" id="S1" value="<?php print $f3->value; ?>"></td>
<td align="center"><input name="S2[]" type="text" id="S2" value="<?php print $f4->value; ?>"></td>
<td align="center"><input name="S3[]" type="text" id="S3" value="<?php print $f5->value; ?>"></td>
<td align="center"><input name="S4[]" type="text" id="S4" value="<?php print $f6->value; ?>"></td>
<td align="center"><input name="S5[]" type="text" id="S5" value="<?php print $f7->value; ?>"></td>
<td align="center"><input name="S6[]" type="text" id="S6" value="<?php print $f8->value; ?>"></td>
<td align="center"><input name="S7[]" type="text" id="S7" value="<?php print $f9->value; $rS->MoveNext(); ?>"></td>
</tr>
<?php
}
?>
<tr>
<td colspan="9" align="center"><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</td>
</tr>
</form>
</table>
<?php
$rS->Close();
$db_conn->Close();
?>
2nd page
<?php
$strConn2 = new COM("ADODB.Connection") or die("Cannot Connect: ADO");
$strConn2->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("./dbExam.mdb"));
// Create a new record set
$rs = new COM("ADODB.Recordset");
$rs->Open("select * from BC101", $strConn2, "3", "1");
$bilPel = $rs->recordcount();
echo $rs->recordcount() ." : Number of records <p></p>";
//close the ADO connections and release resources
$rs->Close();
$strConn2->Close();
$rs = null;
$strConn2 = null;
$strConn = new COM("ADODB.Connection") or die("Cannot connect: ADO");
$strConn->Open("DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("./dbExam.mdb"));
$i = 0;
while ($i < $bilPel){
$S1 = $_POST['S1'][$i];
$S2 = $_POST['S2'][$i];
$S3 = $_POST['S3'][$i];
$S4 = $_POST['S4'][$i];
$S5 = $_POST['S5'][$i];
$S6 = $_POST['S6'][$i];
$S7 = $_POST['S7'][$i];
$id = $_POST['id'][$i];
echo "$S1 , $S2, $S3: $id ... <br />";
$strSQL = "update BC101 set S1 = '$S1', S2 = '$S2', S3 = '$S3',S4= '$S5', S5='$S5', S6='$S6', S7='$S7' where id = '$id'";
$flgSave = $strConn->Execute($strSQL);
++$i;
}
$strConn->Close();
$strConn = null;
?>