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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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