Forum Moderators: coopster

Message Too Old, No Replies

query depending on multiple drop down boxes

php/mysql

         

ksugam

9:08 pm on Nov 21, 2007 (gmt 0)

10+ Year Member



hello everyone,
forgive me if this is a repost.i just registered on this site and could not get the time to go through the postings.

I am having a form with 4 drop down menus. all the drop downs are pre-populated. now i have to query the database depending on the options selected by the user and display the output in a tabular format.

i can do this if i have just 2 drop down boxes but it is getting difficult to handle 4 drop down boxes.

even in the 2 drop downs, when i am trying to use an if else statement, the else part is never executed.

is there any fix format to follow to solve this issue...it would be great if you could make me understand this..

Thanks
Sugam

PHP_Chimp

10:07 pm on Nov 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can you post what you have got as code?
Also you may want to move over to a switch block to avoid if/else if/ else to many times.

ksugam

10:39 pm on Nov 21, 2007 (gmt 0)

10+ Year Member



finally my if..else started working. there was a silly mistake.

PHP_Chimp suggested to use switch statement instead of if.else if.

here are my 4 drop down boxes:
1. Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec, All
2. x1,x2,all
3. yes, no
4. yes, no

the conditions i need to chk is:
for drop down box
1. whether its =all or <>all
2. =all or <>all
3. yes or no
4. yes or no

so according to all permutations and combinations, can you help me write a switch statement?

ksugam

10:23 pm on Nov 28, 2007 (gmt 0)

10+ Year Member




System: The following message was spliced on to this thread from: http://www.webmasterworld.com/php/3515699.htm [webmasterworld.com] by coopster - 7:25 am on Nov. 29, 2007 (utc -6)


I have 4 drop downs boxes on my first web page. I use POST method to pass the value of the drop down boxes to variables.

here is my data for the drop downs:
1. Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec,All
2. a,b,all
3. yes,no
4. yes,no

the check conditions for the above drop downs are as follows:

$var1 = all or any(any month from jan to dec)
$var2 = all or any(any of the values a or b)
$var3 = yes or no
$var4 = yes or no

I started off using if-elseif and it is driving me nuts right now.
e.g. if ($var1==all){
if ($var2==all && $var3==no && $var4==no){}
elseif ($var2==all && $var3==yes && $var4==no){}
...
...
..

so basically i want to design a switch statement for above conditions.

Please help!