This is probably mostly a PHP question, but I will ask it here in case
there is some hidden CakePHP interaction that I am not aware of.

I have a model called Product and I have a view where I list all of
the products.  Each product has a quantity that I want to be update-
able from the list - but all at once, so there is only one submit
button and then I process all quantity updates at once.

I build a new array for the update, updProdQty[], using the product ID
as the key, and the current quantity as the value, and process that
array to update the quantity values... (All of this in a form input
statement)   It works great - but only for the first 200 entries...

The really bizarre thing is that I have 207 products in the db and
they get listed correctly.  But for some reason my array that I build
for update has only 200 entries!!!  but I create an entry in the array
for each item that I print in the list.  Is there any limitation to
the number of items in an array if you are creating the array with
input elements?  Or can anyone think of any other reasons I only get
200 entries?

Here is the view code:

  <form method="post" action="<?php echo $html->url('/products/index')?
>">
  <table id="productInventory">
  <thead>
  <th>Product Name</th>
  <th>Quantity</th>
  <th>Delete</th>
  </thead>
  <?php
        for($i = 0; $i < count($products); $i++) {
                print("<tr>\n<td>");
                echo 
$html->link(htmlspecialchars_decode($products[$i]['Product']
['name'], ENT_QUOTES), "/products/view/".$products[$i]['Product']
['id']);
                print("</td>\n<td>");
                $this_qty = $products[$i]['Product']['quantity'];
                $this_pid = $products[$i]['Product']['id'];
                printf("<input type=\"text\" name=\"updProdQty[$this_pid]\" 
size=
\"5\" value=\"%d\" ", $this_qty);
                if ($this_qty < 0) {
                        print("class=\"negativeQtyBox\" />\n");
                } else {
                        print("class=\"qtyBox\" />\n");
                }
                print("</td>\n<td><input type=\"checkbox\" name=
\"deleteMe[$this_pid]\" /></td>");
                print("</tr>\n");
        }
        print("</table>\n");
        echo $html->submit('Update');
  ?>
  </form>

And here is the controller code:

        function index()
        {
                $this->pageTitle = 'Inventory';
        if (empty($this->params['form'])) {
                        $this->set('products', $this->Product->findAll(null, 
null, 'name
ASC'));
                } else {
                        foreach ($this->params['form']['updProdQty'] as $pid => 
$qty) {
                                $this->Product->updQty($pid, $qty);
                        }
                        if (isset($this->params['form']['deleteMe'])) {
                                foreach ($this->params['form']['deleteMe'] as 
$pid => $qty) {
                                        $this->Product->del($pid);
                                }
                        }
                        $this->set('products', $this->Product->findAll(null, 
null, 'name
ASC'));
                }
        }


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to