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
isabelle
Forum Newbie
Posts: 7 Joined: Mon Jan 17, 2005 2:12 pm
Post
by isabelle » Thu Jan 27, 2005 12:50 pm
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))
{
$id=$rowї"id"];
$products=$rowї"product"];
$options=$products;
print "<OPTION>$options</OPTION>";
} // end while loop body
} // end if $rowsFound body
print "</SELECT>" ."<br>" ."<br>" ;
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jan 27, 2005 12:54 pm
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
Post
by isabelle » Thu Jan 27, 2005 8:10 pm
I am new to PHP so I wanted to ask how I would detect the selection on another page using $_GET.
Thanks.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Thu Jan 27, 2005 8:17 pm
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
Post
by isabelle » Thu Jan 27, 2005 8:32 pm
The closest thing I have to that is:
Code: Select all
$productName = mysqlclean($_GET, "products", 30, $connection);