# IF ELSE LOOP - Different situation...!

**URL:** <https://forum.kirupa.com/t/if-else-loop-different-situation/279668>\
**Category:** programming\
**Created:** [January 17, 2009, 6:02am UTC](https://forum.kirupa.com/t/if-else-loop-different-situation/279668 "2009-01-17T06:02:30Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cyandi\_man](https://avatars.discourse-cdn.com/v4/letter/c/ecae2f/32.png) [@cyandi\_man](https://forum.kirupa.com/u/cyandi_man)\
**Post date:** [January 17, 2009, 6:02am UTC](https://forum.kirupa.com/t/if-else-loop-different-situation/279668/1 "2009-01-17T06:02:30Z")

</div>

Hi Guys - id like to thank you all for helping me thus far. I was wondering if anybody can tell me if there is anything wrong with the following loop. What it is is a directory listing that you can choose the location and service from dropdown menus. then the next page will display a list of locations based on your pick. im not sure… but it seems like the default selections (it is a dropdown menu) are not returning a value. Please help!

```auto

--previous code--
  $db = mysql_select_db($database,$connection)
       or die ("Couldn't select database");

if ($industry=="-Any Dicipline-" && $city !="-Any City-"){
$query = "SELECT * FROM Proffesional_list WHERE city='$city'";
}
else if ($city=="-Any City-" && $industry!="-Any Dicipline-"){
$query = "SELECT * FROM Proffesional_list WHERE industry='$industry'";
}
else if ($city=="-Any City-" && $industry=="-Any Dicipline-"){
$query = "SELECT * FROM Proffesional_list";
}
else if ($city!="-Any City-" && $industry!="-Any Dicipline-"){
$query = "SELECT * FROM Proffesional_list WHERE industry='$industry' AND city='$city'";
}

$result= mysql_query($query)
or DIE("unable to retrieve database info");
rest of the code and echo statements...

```

As you can see, my data is on the Proffesional\_list (I KNOW I SPELLED IT WRONG)  
only when i choose an actual item and location - the list is displayed - but when i choose one or the other or none at all - i get a blank listing.

The page with the dropdown menu precedes the page with the above code…  
The dropdown menu in question is coded in php like so:

```auto

$query2 = "SELECT DISTINCT city FROM Proffesional_list ORDER BY city";
  $result2 = mysql_query($query2)
       or die ("Couldn't execute query.");

  /* create form containing selection list */
  echo "<form action='code/memberdisplaylist.php' name='list1_form'>
        <select name='industry'>
";
echo "<option value='$industry'>-Any Dicipline-
";//<--this should be the default value
  while ($row = mysql_fetch_array($result))
  {
     extract($row);
     echo "<option value='$industry'>$industry
";
  }
  echo "</select>
";
  ?>

```

Is the default &industry value coded correctly?  
The items in the industry dropdown are pulled dynamically from the database - except for the default value.  
Please help! Thanks in advance!
