Jump to content

IF ELSE LOOP - Different situation...!


cyandi_man

Recommended Posts

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!

--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:

$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'>\n";
echo "<option value='$industry'>-Any Dicipline-\n";//<--this should be the default value
  while ($row = mysql_fetch_array($result))
  {
     extract($row);
     echo "<option value='$industry'>$industry\n";
  }
  echo "</select>\n";
  ?>

 

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!

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.