select all

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
isabelle
Forum Newbie
Posts: 7
Joined: Mon Jan 17, 2005 2:12 pm

select all

Post 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>" ;
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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..
isabelle
Forum Newbie
Posts: 7
Joined: Mon Jan 17, 2005 2:12 pm

detecting selection

Post by isabelle »

I am new to PHP so I wanted to ask how I would detect the selection on another page using $_GET.

Thanks.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

check $_GET['products'] to see if it's equal to the unique value you add for 'All'
isabelle
Forum Newbie
Posts: 7
Joined: Mon Jan 17, 2005 2:12 pm

GET

Post by isabelle »

The closest thing I have to that is:

Code: Select all

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