Re: Update multiple records from a text field
| From: | kaizer boab | Date: | Fri, 02 Apr 2004 18:50:44 +0000 |
| Subject: | Re: Update multiple records from a text field | ||
| References: | 1 2 3 4 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-23356@lists.php.net to get a copy of this message | ||
I have changed it to name="qty[]" . How would I reference it on my
processing script?
"Justin Patrin" <papercrane@reversefold.com> wrote in message
news:20040402184037.46651.qmail@pb1.pair.com...
> Kaizer Boab wrote:
>
> > Hi Justin,
> >
> > I only have the one qty field in the View Cart page. It is part of a
loop to
> > pull out all the quantities from the cart. It is retrieved via the
script
> > below:
> >
> > <?php
> > // Query the cart table and select all the items from the table.
> > $resultCart = mysql_query("SELECT * FROM cart, products WHERE
> > cart.albumId = products.albumId AND cart.trackerId = $trackerId ORDER by
> > products.albumTitle ASC");
> > while($row_rsCart = mysql_fetch_array($resultCart))
> > {
> > $cost = $row_rsCart['albumPrice'] * $row_rsCart['qty'];
> > $cost = number_format ($cost, 2);
> > $subTotal = number_format ($subTotal, 2);
> > $subTotal += $cost;
> > ?>
> > <tr>
> > <td align="left"><?php echo
$row_rsCart['albumArtist'];?></td>
> > <td align="left"><?php echo
$row_rsCart['albumTitle'];?></td>
> > <td align="right"><?php echo $cost;?></td>
> > <td align="right
> > <input name="qty" type="text" size="2"
> > value="<?php echo
> > $row_rsCart['qty'];?>" />
> > </td>
> > </tr>
> > <?php }// END while loop;?>
> >
> > Since the qty text field is only one box in a loop, naming it won't
help. Is
> > there another way I could achieve the update?
> >
> > Thanx for your help.
> >
> >
> >
> >>Looks like you're naming all of your quantity text boxes "qty". You need
> >>to use different var names to make multuple values come back. For
> >>instance you could use "qty[]" to have the results come back in an
> >>array. Or you could use qty[x] where x is a specific # so that you know
> >>which product to update.
> >>
> >>--
> >>paperCrane <Justin Patrin>
>
> You need to use what I said in my reply. Change name="qty" to
> name="qty[]" or name="qty[some database id]".
>
> --
> paperCrane <Justin Patrin>