Jump to content

If & Elseif Statements


Recommended Posts

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/dropdowns

kind regards
DD

If ($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());
}

Link to comment
https://forums.phpfreaks.com/topic/13140-if-elseif-statements/
Share on other sites

[!--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 variations
currently 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=X
Records of Any Type and of Value =X and in Area=X
Records in Any Area and of Type=X and of Value=X
Records in Area=X and of Type=X and of Value=X - this works currently
And 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 grateful

DD
Link to comment
https://forums.phpfreaks.com/topic/13140-if-elseif-statements/#findComment-50551
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.