Re: passing multiple vars?
| From: | Matthew Leverton | Date: | Fri, 07 Jul 2000 20:18:52 +0000 |
| Subject: | Re: passing multiple vars? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-5444@lists.php.net to get a copy of this message | ||
Quite simple actually. PHP handles it the most gracefully out of all
the languages I've used.
<select name="bookids[]" multiple>
<option></option>
...
</select>
This will pass an array to php. You can use something like this
to loop through:
for ($i=0; $i<sizeof($bookids); $i++) {
// bookids[$i];
}
Or you could dump the array into a comma dilimited string and use
something like:
"DELETE FROM Books WHERE Book_ID IN ($comma_list)"
(That may not be the exact SQL, but something along those lines.)
Check up on the array functions in the manual for more info, or
email me and I can be more specific.
--
Matthew Leverton - matthew@aeroinc.net -
http://www.allegro.cc
-----Original Message-----
From: Paulson, Joseph V. "Jay" <jay.paulson@viatel.com>
To: php-general@lists.php.net <php-general@lists.php.net>
Date: Friday, July 07, 2000 3:13 PM
Subject: [PHP] passing multiple vars?
>Hello everyone--
>
>Okay well I have a slight problem. I have a database of books with the
>fields of:
>
>Book_ID
>Title
>Description
>
>What I am trying to do is be able to delete multiple entries at the same
>time. I have my SQL statement print out all the book id's and book titles
>in a multiple select menu in the browser and then I press the "Delete Book"
>button at the bottom of the page.
>
>Here's the problem: how do I retireve all the book id's that I have
selected
>from the previous page? After I press the "Delete Book" button it only
>passes one of the book id's instead of multiple id's. I really want to use
>the <select><option> tags and not something like checkboxes because I don't
>want hundreds of book titles printed to the screen and have the user scroll
>down a huge page to check the boxes of which books he/she wants to delete.
>
>Anyway, any ideas on how I can pass all the values that I select on to the
>next page?
>
>Here's a snippet of the form code I am using:
>
>echo "<select name=\"bookID\" size=\"10\" multiple>\n";
>for ($i=0; $i<$maxArraySize; $i++) {
> echo "<option
> value=\"".$book["BOOK_ID"][$i]."\">".$book["TITLE"][$i])."
></option>\n";
> } //end of for
>echo "</select>\n";
>
>thanks,
>jay
>
>--
>PHP General Mailing List (http://www.php.net/)
>To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
>For additional commands, e-mail: php-general-help@lists.php.net
>To contact the list administrators, e-mail: php-list-admin@lists.php.net
>