RE: [PHP] update query based on array
| From: | Ford, Mike [LSS] | Date: | Tue, 10 Dec 2002 11:20:58 +0000 |
| Subject: | RE: [PHP] update query based on array | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-127620@lists.php.net to get a copy of this message | ||
> -----Original Message-----
> From: Jason Dulberg [mailto:jdulberg@nas.net]
> Sent: 09 December 2002 23:52
>
> So you mean do something like:
>
> <input type="text" name="category[15]" value="Prep School">
> <input type="text" name="rank[15]" value=30 size=4>
> <input type="checkbox" name="rankid[15]" value="166">
>
> Doesn't that create 2 additional arrays though?
Yes -- but how else are you going to get multiple values for each name from
your form to your PHP script? Without the array subscripts on both category
and rank, you will only ever get one category and one rank passed to your
script.
Using the above, just do:
foreach ($_POST['rankid'] as $row, $rankid):
// in here, $rankid is the value of the current rankid[]
// $_POST['category'][$row] is associated category[] value
// $_POST['rank'][$row] is associated rank[] value
endforeach;
Cheers!
Mike
---------------------------------------------------------------------
Mike Ford, Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS, LS6 3QS, United Kingdom
Email: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211