43rdworld
43rdworld

Reputation: 97

For loop stops passing variables after 332 iterations - can't figure out why

I'm working on an admin tool that the internal customer wants to update multiple entries at the same time. Combining two excellent answers to a question I posted in June, I've created a development form for the project. The form works fine up to record 332 - shows what you've updated at the top of the form. But change the id range to anything over 332 and it the form stops passing data and nothing shows at the top.

I need to sort this out for use on the production form but wanted to work out the kinks on a smaller version first. I suspect it has something to do with a browser or system limit but am not sure on that point.

Code is below - would really appreciate some help with this. If I can't get it to work, I'll have to revert to updating records individually and the customer will hate that. Also, I apologize if this is a dupe of anything - I've been looking but really haven't found anything quite relevant to this, except my previous question in June. Thanks in advance.

<?php
    $ids = range(1, 332); // [1, 2, 3];
    if(isset($_POST['updateFormData'])) {
        if ((strtolower($_POST['updateRecord']) == "update")) {
            foreach ($_POST['update'] as $key => $update) {
                $id = $_POST['id'][$key];
                $regOK = (
                    isset($_POST['regOK'][$key]) ?
                    $_POST['regOK'][$key] : false
                );
                $paidOK = (
                    isset($_POST['paidOK'][$key]) ?
                    $_POST['paidOK'][$key] : false
                );
                $ebdOK = (
                isset($_POST['ebdOK'][$key]) ?
                    $_POST['ebdOK'][$key] : false
                );
                $appOK = (
                isset($_POST['appOK'][$key]) ?
                    $_POST['appOK'][$key] : false
                );
                $notes = (
                isset($_POST['notes'][$key]) ?
                    $_POST['notes'][$key] : false
                );
                echo "RECORD ID: ".$id."<br>";
                echo " REG: ".$regOK."<br>";
                echo "PAID: ".$paidOK."<br>";
                echo " EBD: ".$ebdOK."<br>";
                echo " APP: ".$appOK."<br>";
                echo "NOTES: ".$notes."<br><br>";
            }
        }
    }
    echo "<br>";
?>
<style type="text/css">
    th,td {text-align:center;}
    .test {width:22px;height:22px;margin:0;}
</style>
<form action="" method="post" name="theForm">
    <table cellpadding="2" cellspacing="0" class="resultsTable">
        <tr>
            <th>REG</th>
            <th>PAID</th>
            <th>EBD</th>
            <th>APP</th>
            <th>Update Record</th>
        </tr>
        <?php foreach($ids as $id) { ?>
        <tr>
            <td><input type="checkbox" name="regOK[<?=$id?>]" id="regOK" value=""></td>
            <td><input type="checkbox" name="paidOK[<?=$id?>]" id="paidOK" value="1" ></td>
            <td><input type="checkbox" name="ebdOK[<?=$id?>]" id="ebdOK" value="1" ></td>
            <td><input type="checkbox" name="appOK[<?=$id?>]" id="appOK" value="1" ></td>
            <td><input type="text" name="notes[<<?=$id?>]" id="appNotes" class="col250" value=""></td>
            <td>
                <input type="checkbox" class="test" name="update[<?=$id?>]" id="update" value="<?=$id?>">
                <input type="hidden" name="updateRecord" id="updateRecord" value="update">
                <input type="text" name="id[<?=$id?>]" id="id" value="<?=$id?>"  />
            </td>
        </tr>
        <?php }?>
        <tr><td colspan="5" ><input type="submit" name="updateFormData" id="updateFormData" value="Update All Records"></td></tr>
    </table>
</form>

I would expect the form to update any record and show it in the echos at the top of the form, no matter how many iterations it goes through instead of quitting after 332.

Upvotes: 0

Views: 44

Answers (1)

43rdworld
43rdworld

Reputation: 97

I figured it out - started searching on a post limit and found the php max_input_vars setting. The php ini was defaulting to a 1000 vars. I upped the amount pretty high and am passing data up to 5000 records at the moment.

Don't know what performance impact I may be looking at, but it's an internal server used only by a handful of employees, so low impact, light load.

Upvotes: 1

Related Questions