Batch update record with Pagination

Posted on 16th Feb 2014 by admin

Hoping someone can help me with this issue I'm having, im trying to batch update records from a result set with pagination. The first page results (first 10 records) will update with the batch, but any other pages will not update.... the pagination coding is preventing the rest of the results to update when a date change is made.

Here's the code im using:

<div class="searchTitle">SCHEDULING</div>
<div class="tabber" id="mytab1">
<div class="tabbertab">
<h2>RECORDS</h2><form name="namestoupdate" method="post" action="updateschedule.php">
<div class="searchTitle">RECORDS<input type='submit' class="submitButton" value='SUBMIT' src="images/submit.png" /></div>


<table cellspacing="0" id="box-table-a">
<tr>
<th>TITLE</th>
<th>DATE</th>
</tr>
<?php
$i = 0;
while ($result_row = mysql_fetch_array($resultbypass)) {
if($i< $startbypass || $i>=$stopbypass) { $i++; continue; }
$i++ ; ?>
<tr>
<td><?php print "<input type='hidden' name='ID[$i]' value='{$result_row['ID']}' />" ?> <?php echo $result_row['Provider']; ?></td>
<td><?php echo $result_row['Title']; ?></td>
<td><?php print "<input type='text' size='8' name='Date[$i]' value='{$result_row['Date]}' maxlength='10' />";
?></td>
</tr>
<?php } ?>
</table>
<?php echo getPaginationString($pagebypass,$totalitemsbypass,$itemsPerPage,1,$targetpage,$pagestringbypass); ?>

</form>
</div>


Batch update script: (updateschedule.php)

<?php
session_start();

include("connect.php");

$size = count($_POST['ID']);

$i = 0;
while ($i <= $size) {

$Date= $_POST['Date'][$i];
$id = $_POST['ID'][$i];

$query = "UPDATE Table
SET Date= '$Date'
WHERE ID = '$id' LIMIT 1";

mysql_query($query) or die ("Error in query: $query");

++$i;
}
mysql_close();

?>

Other forums