Duncan Disorderly Posted June 28, 2006 Share Posted June 28, 2006 I would be grateful if someone could tell me the correct syntax to use with the code below. Additionally, is there some method I can use to process an "any / all records" option from a series of combo box/dropdownskind regardsDDIf ($l_Type==1 AND $L_Area==1 AND $L_value==1) {$result = mysql_query("Select * FROM listings")or die(mysql_error());} elseif ($l_Type>1 AND $L_Area==1 AND $L_Value==1) {$result = mysql_query("Select * FROM listings WHERE listings.`Type`='$L_Type'")or die(mysql_error());} elseif($l_Type==1 AND $L_Area>=1 AND $L_Value==1) {$result = mysql_query("Select * FROM listings WHERE listings.`Area`='$L_Area'")or die(mysql_error());} elseif($l_Type==1AND $L_Area==1 AND $L_Value>1) {$result = mysql_query("Select * FROM listings WHERE listings`.`Value`='$L_Val'")or die(mysql_error());} elseif($l_Type>1 AND $L_Area>1 AND $L_Value==1) {$result = mysql_query("Select * FROM listings WHERE listings.`Type`='$L_Type' AND `listings`.`Area`='$L_Area'")or die(mysql_error());} elseif($l_Type>1 AND $L_Area==1 AND $L_Value>1) {$result = mysql_query("Select * FROM listings WHERE listings.`Type`='$L_Type' AND `listings`.`Value`='$L_Val'")or die(mysql_error());} elseif($l_Type==1 AND $L_Area>1 AND $L_Value>1) {$result = mysql_query("Select * FROM listings WHERE listings`.`Value`='$L_Val' AND `listings`.`Area`='$L_Area'")or die(mysql_error());} else {$result = mysql_query("Select * FROM listings WHERE listings.`Type`='$L_Type' AND `listings`.`Value`='$L_Val' AND `listings`.`Area`='$L_Area'")or die(mysql_error());} Quote Link to comment https://forums.phpfreaks.com/topic/13140-if-elseif-statements/ Share on other sites More sharing options...
cmgmyr Posted June 28, 2006 Share Posted June 28, 2006 try putting the "I" in lowercase "if"is something else not working? Quote Link to comment https://forums.phpfreaks.com/topic/13140-if-elseif-statements/#findComment-50526 Share on other sites More sharing options...
Duncan Disorderly Posted June 28, 2006 Author Share Posted June 28, 2006 [!--quoteo(post=388954:date=Jun 28 2006, 02:14 PM:name=cmgmyr)--][div class=\'quotetop\']QUOTE(cmgmyr @ Jun 28 2006, 02:14 PM) [snapback]388954[/snapback][/div][div class=\'quotemain\'][!--quotec--]try putting the "I" in lowercase "if"is something else not working?[/quote]cmgmyr,Thanks, lowercase "I" indeed helped, .....THIS NEEDS TO BE READ INCONJUNCTION WITH THE CODE IN MY ORIGINAL POST......However (Hope you can follow this!....) I have three dropdowns, type, area and value, a user can select a value from "each box (or they default to "Any"- value =1) to search on. Problem: Selecting the "any record" (ie: value==1) option from any of the three dropdowns does not select "All" records of that option.Ie: if all three dropdowns were set to "any" it would mean.. Display all records of "any value" and "in any area" and "of any type" or variationscurrently as long as the dropdowns are NOT set to "any" the search works.I want to be able to select:All records (any,any,any)Records of Any Value and of Type=X and in Area=XRecords of Any Type and of Value =X and in Area=XRecords in Any Area and of Type=X and of Value=XRecords in Area=X and of Type=X and of Value=X - this works currentlyAnd variations of the above..if anyone can understand my babble above and offer some sound advice (other than give up..lol) I would be most gratefulDD Quote Link to comment https://forums.phpfreaks.com/topic/13140-if-elseif-statements/#findComment-50551 Share on other sites More sharing options...
Duncan Disorderly Posted June 28, 2006 Author Share Posted June 28, 2006 ResolvedTip for all Noobies like me.... check your capitalisation... variables are case sensitive .... I had "If" when it should be "if" (thx cmgmyr) and "$l_Type" when it should be "$L_Type"Dowh... hrs wasted...DD46 y.o idiot! Quote Link to comment https://forums.phpfreaks.com/topic/13140-if-elseif-statements/#findComment-50609 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.