Jump to content

[SOLVED] Filtering records based on menu option selected


Recommended Posts

I am currently in the process of refining an IT helpdesk system and I am trying to implement filtering.

 

At the minute, all calls for a user show up when they log in.

 

What I would like is for them to select an option from a drop down menu, and then only records matching the criteria will be shown.

 

I've coded this in PHP with the correct SQL statements, whereby it takes the value currently set in a list/menu and selects the certain records based on the if statements.

 

My question is......how do i get the page to remember that the option has been changed and only display the corresponding records? I have a "go" button which submits the form to itself and reloads the page, but I can't quite figure out how to pass the value of the selected option back, as the default option just keeps reloading.

 

however, if i echo the contents of the menu, it does show what i have selected...but does not show these records only..

 

Thanks!

 

 

 

I have done this but only got it to work for IE and not FF

 

But heres what I did:

 

<select name="genres" onchange="location.href=genres.options[selectedIndex].value" style="width: 75px; font-size: 7pt;">
                  <option selected="selected">Genres..</option>




                  <option value="page.php?query=value" >Action</option>
                  <option value="page.php?query=value" >Arcade</option>
                  <option value="page.php?query=value" >Platform</option>
                  <option value="page.php?query=value" >Puzzle</option>
                  <option value="games.php?g=Shooting" >Shooting</option>
                  <option value="page.php?query=value" >Sports</option>
                  <option value="page.php?query=value" >Assorted</option>

                </select>

 

Obviously change accordingly

 

Oh and this will redirect automatically. To get the value either use $_GET or $_POST

ChrisUK, are you using GET or POST method in your form or is everything on the URL?

 

Doesn't really matter if you use the $_REQUEST global super variable.

 

I think what you want to do is:

 

<php

if( isset( $_REQUEST['selected'] ) )
{
  switch( $_REQUEST['selected'] )
  {
    case 'Action' : include_once 'action.php';
  }
}

?>

 

Something like this? Your code is a little confused  :)

 

See how I check the value of the variable, then include the correct php page.

 

See how you could write out the header of the page (your site logo, menus and stuff) then include the correct page, e.g. games, then after you could write out the footer (bottom of page, copyright, date time etc)

 

1. display top of page

2. display menu

3. look at 'selected' and include that bit

4. finish page

 

cheers

 

monk.e.boy

 

monk.e.boy

gents - a thousand.....actually no...a million thankyous.

 

On reflection that's pretty simple but I just couldn't for the life of me get it to work!

 

Working great now, exactly what i needed.

 

Oh how I love the internet!

 

Thanks again.

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.