wernervantonder Posted September 15, 2006 Share Posted September 15, 2006 I have two list boxes on a form on my webpage. I have a database that contains 9 fields including the two indexes : Area and Category.Now what i want to do in sql is if i select a area in the first list box and then i select a category in the seccond list box i press a button Called find. I want to assign those current values to a variable and then use my select statement to filter those fields and display it.How do i go about doing that. I do not want you guys to do my work for me i just want an idea as to the working on this. What wording do i use to assign the values of the list box to a variable.Thank you so muchWerner Quote Link to comment Share on other sites More sharing options...
markbett Posted September 15, 2006 Share Posted September 15, 2006 its not entirely clear what you are trying to do but perhaps you are looking to create dynamic dropdowns from variables in your db then take the value of the selection in the dropdown when the user submits and pass that into the sql query... so you would need to do $filter=value(dropdown1) $filter2=value(dropdown2)sql query= select blah from foo WHERE $filter = value and $filter2 = somethign else Quote Link to comment Share on other sites More sharing options...
JustinK101 Posted September 15, 2006 Share Posted September 15, 2006 Not sure I fully understand. But what is sounds like is you have a form, with two list boxes, you make the submit button labeled Find, when they click find the page reloads and values of the listboxes are posted, either GET or POST and then you simply append those variables in your MYSQL WHERE clause. I could be way off though. Quote Link to comment Share on other sites More sharing options...
JustinK101 Posted September 15, 2006 Share Posted September 15, 2006 What is value(dropdown1)? I could be wrong, but I am aware of a PHP method call named value(). Quote Link to comment Share on other sites More sharing options...
markbett Posted September 15, 2006 Share Posted September 15, 2006 lol its me being stupid and writing it out as a function cause its 2am.... its not a function it should just be whatever value was selected from the dropdown menu..... Quote Link to comment Share on other sites More sharing options...
wernervantonder Posted September 15, 2006 Author Share Posted September 15, 2006 Thanx guys it is greatley appreciated, You got the right idea i basicaly want to take the selections made in listboxes and click submit button and execute php where i assign those values to variables :$area and $category with sql that says select*from databseWHERE $area = listbox1and $category = listbox2.so my question is wht wording do i use to assign those listboxes selected content to variable?thanks werner Quote Link to comment Share on other sites More sharing options...
JustinK101 Posted September 15, 2006 Share Posted September 15, 2006 Once you submit the form, the values of the boxes are sent to method, either GET or POST. So you can access them by:$_GET['listbox_name'] or $_POST['listbox_name'] IF YOU HAVE REGISTER GLOBALS ON, THEN YOU CAN ACCESS BY SIMPLY:$listboxname Quote Link to comment Share on other sites More sharing options...
wernervantonder Posted September 16, 2006 Author Share Posted September 16, 2006 Thank you for your help it helped. how ever i have a new question please assist me if you can!The subject is called : mysql_numrows(): I realy appreciate your help!Werner Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.