Jump to content

Newbie Here... Need help with Pull Down Dynamic Menu`s


Recommended Posts

Hi, Im in the middle of writing an online catalogue for my Company and as an Exercise for me to learn More about PHP and Mysql etc.. All is working fine but i need a few Pointers if anyone can help..

1st Problem..
When my Form loads with the Dynamic Content it always shows tthe last record? I understand this is Normal, But from From all the Websites ive ever visted, ive never once seen this put into Practice? Most have a "please Choose" or a Name for the pull Down menu ie a Sports Site might have "Trainers" and then when you access the menu you see the trainers you can Choose?

2nd problem..
I have 2 Pull Down menus and 1 Submit button that Filters out the results from the Menus, Works Lovely, But it would be handy if you could Choose just One of the pull down menus and the 2nd one displayed all of the results from that Category.. let me give you an Example :-

Pull Down Menu 1 is Trainers Pull Down menu 2 is Colour

Right now you can Choose Nike and White from the Menus and press Submit and you see all White Nike trainers.. But what if i wanted to list all Nike Trainers? how can i Add an All Category to the Colour Menu? and Vise Versa?

Im Still Pretty New to PHP but have a Fairly Good Understanding as ive got this Far...

Thanks for Reading... Hope it made Sense...

Paul.
Link to comment
Share on other sites

Hi, Managed to Solve Problem One... Added Static menu item and Blanked out the Select value equal to Box..

Can anyone help with the SQL for problem 2, The Static Menu Options have a value of 0, Which Means if the Form is Submitted without Changing the Default value Nothing Happens...

Paul.
Link to comment
Share on other sites

  • 6 months later...
Hey there,

I am having the same issue...also, when you create the pulldown dynamically, where is the selected value set to a variable??  Here is the code DreamW. creates for my pulldown:

<select name="select2">
          <?php
do { 
?><option value="<?php echo $row_rsFirstName['FirstName']?>"><?php echo $row_rsFirstName['FirstName']?></option>
          <?php
} while ($row_rsFirstName = mysql_fetch_assoc($rsFirstName));
  $rows = mysql_num_rows($rsFirstName);
  if($rows > 0) {
      mysql_data_seek($rsFirstName, 0);
  $row_rsFirstName = mysql_fetch_assoc($rsFirstName);
  }
?>
        </select>

rsFirstName being just a recordset of all the firstnames  in my database table.  I just need to know where the form variable is being set up there...???

-thanks
Link to comment
Share on other sites

  • 3 weeks later...
HI!
Select your Dropdown, click on ListValues and add one Item Label called "All" or whatever you want to call it, now for the "All" thing to work, you have to assign a '%' Value (without the quotes) that way, when the form passes it, I will pass it as % and will work as a wildcard on your query. Lastly you have to modify the recordset query in your results page to use 'like' instead of '='

EXAMPLE:
Select trainer, colour
from your_table where trainer='trainer' and colour like 'colour'

Both 'triner' and 'colour' will be replaced with what you had in the form

Works like a charm!

Good luck
Demian

[quote author=mysq_hell link=topic=84179.msg339614#msg339614 date=1138144253]
Hi, Managed to Solve Problem One... Added Static menu item and Blanked out the Select value equal to Box..

Can anyone help with the SQL for problem 2, The Static Menu Options have a value of 0, Which Means if the Form is Submitted without Changing the Default value Nothing Happens...

Paul.
[/quote]
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.