Jump to content

Filter Drop down menu options


yandoo

Recommended Posts

Hi there,

 

Im trying to filter the options displayed in a drop down menu (adds Fear names, 1 at a time)  that when updated, the user is directed to the same page. Once the update has been doner the user sees the same page with same drop down menu, but additionaly a php echo displays what the user has inputed... (so initally each time the user adds a fear a query selects all the fears that that user has inputed)

 

All above works like a charm!

 

 

My problem is that i need some vallidation on the drop down menu, so that only the fear names that the user has NOT inserted appears only! This will ensure the user can NEVER add the same fear name!!

 

Its funny really because the query i created to display what fear names the user has just inserted works fine and i need like the complete OPPOSITE of what the query SELECT.

 

Heres the line of code that displays the records the user has just inserted:

mysql_select_db($database_woodside, $woodside);
$query_animalFear2 = "SELECT FearID FROM animalfears WHERE AnimalID='" . $row_animalFear['AnimalID'] . "'";
$animalFear2 = mysql_query($query_animalFear2, $woodside) or die(mysql_error());
$row_animalFear2 = mysql_fetch_assoc($animalFear2);
$totalRows_animalFear2 = mysql_num_rows($animalFear2);

 

<?php echo $row_animalFear2['FearID']; ?>

- Added into repaeat region to display user inserted records.

 

Here is the drop down menu code (needs validation added to it?):

<select name="fearid" id="fearid">
          <?php
do {  
?>
          <option value="<?php echo $row_fears['FearID']?>"><?php echo $row_fears['FearID']?></option>
          <?php
} while ($row_fears = mysql_fetch_assoc($fears));
  $rows = mysql_num_rows($fears);
  if($rows > 0) {
      mysql_data_seek($fears, 0);
  $row_fears = mysql_fetch_assoc($fears);
  }
?>
        </select>

 

I just need to some how query it so that the the query brings up all the records ACCEPT for ones that are displayed

 

Any help would be much appreciated!

 

Thank You:)

Link to comment
Share on other sites

I feel i should add at this point that....

 

The drop down menu displays all the fears in a table !

 

The query that displays the fears the user has entered comes from the AnimalFear table (which contains  AnimalFearID ,FearID and AnimalID) This is what the user is updating.

 

So the query i have made SELECTS all FearID's from the Fears table  WHERE the animalFearID is =  animalFear [AnimalID]

 

I neeed the valiidation of the drop down menu to be used with the FEARS table not the AnimalFears table(which is what is queried to display users input)

 

Hope this kinda helps...

 

Thank You

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.