note 37887 modified in language.variables.external by danbrown

From: Date: Wed, 09 Mar 2011 14:41:45 +0000
Subject: note 37887 modified in language.variables.external by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-177709@lists.php.net to get a copy of this message
This function is a simple solution for getting the array of selectes from a checkbox list or a dropdown list out of the Querry String. I took an example posted earlier and simplified it. <?php function multi_post_item($repeatedString) { // Gets the specified array of multiple selects and/or // checkboxes from the Query String $ArrayOfItems = array(); $raw_input_items = split("&", $_SERVER["QUERY_STRING"]); foreach ($raw_input_items as $input_item) { $itemPair = split("=", $input_item); if ($itemPair[0] == $repeatedString) { $ArrayOfItems[] = $itemPair[1]; } } return $ArrayOfItems; } ?> Use the name of the field as the agrument. Example: <?php $Order = $_GET['Order']; $Name = $_GET['Name']; $States = multi_post_item('States'); $Products = multi_post_item('Products'); ?> Be sure to check for NULL if there are no selections or boxes checked. --was-- This function is a simple solution for getting the array of selectes from a checkbox list or a dropdown list out of the Querry String. I took an example posted earlier and simplified it. function multi_post_item($repeatedString) { // Gets the specified array of multiple selects and/or // checkboxes from the Query String $ArrayOfItems = array(); $raw_input_items = split("&", $_SERVER["QUERY_STRING"]); foreach ($raw_input_items as $input_item) { $itemPair = split("=", $input_item); if ($itemPair[0] == $repeatedString) { $ArrayOfItems[] = $itemPair[1]; } } return $ArrayOfItems; } Use the name of the field as the agrument. Example: $Order = $_GET['Order']; $Name = $_GET['Name']; $States = multi_post_item('States'); $Products = multi_post_item('Products'); Be sure to check for NULL if there are no selections or boxes checked. http://php.net/manual/en/language.variables.external.php

« previous php.notes (#177709) next »