Jump to content


Photo

Search in php


  • Please log in to reply
7 replies to this topic

#1 wernervantonder

wernervantonder
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 15 September 2006 - 08:32 AM

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 much

Werner

#2 markbett

markbett
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 15 September 2006 - 08:38 AM

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

#3 JustinK101

JustinK101
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego, California, US

Posted 15 September 2006 - 08:40 AM

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.

#4 JustinK101

JustinK101
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego, California, US

Posted 15 September 2006 - 08:43 AM

What is value(dropdown1)? I could be wrong, but I am aware of a PHP method call named value().

#5 markbett

markbett
  • Members
  • PipPipPip
  • Advanced Member
  • 133 posts

Posted 15 September 2006 - 08:45 AM

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.....

#6 wernervantonder

wernervantonder
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 15 September 2006 - 09:22 AM

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 databse
WHERE $area = listbox1
and $category = listbox2.

so my question is wht wording do i use to assign those listboxes selected content to variable?

thanks werner

#7 JustinK101

JustinK101
  • Members
  • PipPipPip
  • Advanced Member
  • 503 posts
  • LocationSan Diego, California, US

Posted 15 September 2006 - 04:56 PM

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

#8 wernervantonder

wernervantonder
  • Members
  • PipPip
  • Member
  • 17 posts

Posted 16 September 2006 - 06:54 PM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users