Page 1 of 1

select all

Posted: Thu Jan 27, 2005 12:50 pm
by isabelle
I've been looking around forums/google and can't find the answer to my problem. I want to include a "select all" option in a drop down menu. I am populating the menu dynamically. So here the the code:

Code: Select all

print "Product: ";
         		print "<SELECT NAME='products' onChange='this.form.submit();'>";
         		print "<OPTION value=''>Select a product</OPTION>";
         		print "<OPTION value=''>All</OPTION>";

          		$options="products";
		 		while ($row = @ mysql_fetch_array($result))
		 			&#123;

					$id=$row&#1111;"id"];
 					$products=$row&#1111;"product"];
					$options=$products;

           			print "<OPTION>$options</OPTION>";
 			
         			&#125; // end while loop body

		
     			&#125; // end if $rowsFound body

         		print "</SELECT>" ."<br>" ."<br>" ;

Posted: Thu Jan 27, 2005 12:54 pm
by feyd
change the value of "All" to a usable one, like * or something that won't appear in the normal list.

you can then detect that selection via $_POST['products'] == '*'

assuming you are posting..

detecting selection

Posted: Thu Jan 27, 2005 8:10 pm
by isabelle
I am new to PHP so I wanted to ask how I would detect the selection on another page using $_GET.

Thanks.

Posted: Thu Jan 27, 2005 8:17 pm
by feyd
check $_GET['products'] to see if it's equal to the unique value you add for 'All'

GET

Posted: Thu Jan 27, 2005 8:32 pm
by isabelle
The closest thing I have to that is:

Code: Select all

$productName = mysqlclean($_GET, "products", 30, $connection);