RE: Update undefined List Values in DB
| From: | Tim Ward | Date: | Mon, 23 Sep 2002 09:24:18 +0000 |
| Subject: | RE: Update undefined List Values in DB | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-117253@lists.php.net to get a copy of this message | ||
make your checkboxes in the form an array with the index being the customer
id.
e.g.
in the form ...
foreach($customers as $cust)
{ echo("<tr>");
...
echo("<input type='hidden' name='status[{$cust["id"]}]'
value='0'>");
echo("<input type='checkbox'
name='status[{$cust["id"]}]'");
if ($cust["status"]) echo(" checked");
echo(">");
...
echo("</tr>");
}
and when processing
foreach($_POST["status"] as $custid=>status)
{ ... // update query for each customer
}
Tim
www.chessish.com
> -----Original Message-----
> From: Sascha Braun [mailto:saschabraun@gmx.de]
> Sent: 22 September 2002 18:43
> To: PHP Mailingliste
> Subject: Update undefined List Values in DB
>
>
> Hi,
>
> I am creating a kind of Shopsystem right now.
>
> One of the Funktions is going to be the possibiliy that the
> page admin can set an customer status to 1 or 0
> via an listing of all customers.
>
> My Problem is, that I have to change more than one value at a
> time due to the Listing, where all
> customers are listed in one big list.
>
> So I have to write multiple values in to the database as Update.
>
> I don't have a clue how to do this, the only thing i could do is
> to make the change possible via an extrapage per customer,
> but I'm not able to change all values at a time.
>
> Would be nice if somebody would give me a hint.
>
> Please excuse my english
>
> Sascha Braun
>