Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2008
    Location
    Blackpool, UK
    Posts
    176
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Populating results query based on Selection in a drop down box

    Hi guys

    I have a drop down box, which is populated by a table called portfolio_cat.

    It has 3 id's in it, 1, 2 and 3.

    This portfolio_cat table is linked up to a table called portfolio which has info on details of a specific job. Ie Location, Jobtitle, ID, Images and cat_id (this one is linked to the portfolio_cat table.)

    Basically when a user clicks on the drop down and selects ID 2 for example.
    I want it to pull out all the information in the portfolio table that has a cat_id of 2 and display it on the page.


    How the hell do I do that????


    Any help would be great


    Danny

  • #2
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    if you want it to respond to an action on the user end you need a client side scripting language ie js


    i think what you really want is ajax. you can rig it to drop whatever info you want into the page on the fly based on the user's choice.

  • #3
    Regular Coder
    Join Date
    Jul 2008
    Location
    Blackpool, UK
    Posts
    176
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Hi


    As i don't have any experience with Javascript or Ajax, would it be easier if I had three links instead of a drop down????

    Then when they click on a link it will transfer them to a page where it will display all records with a value of 1, or a page displaying all records with a value of 2 etc???


    Or does anybody have the code I need to do it through a drop down


    Any help, advice or code would be appreciated.


    Cheers

  • #4
    Regular Coder ohgod's Avatar
    Join Date
    Jun 2008
    Location
    Ohio
    Posts
    579
    Thanks
    6
    Thanked 69 Times in 69 Posts
    you know what, i didn't read that closely enough the first time.


    if you're fine with a dropdown and a submit button, and you're fine with the page refresh then you don't need js or ajax etc



    PHP Code:
    <?
    if(!ISSET($_POST['dropdownvalue'])){
    display the dropdown etchtml code and form goes herepost to self
    }else{
    $id strip_tags($_POST['dropdownvalue']);
    $query 'SELECT `stuff` FROM `somewhere` WHERE `ID` = "'.mysql_real_escape_string($id).'"';

    run the $querydisplay the results as normal

    }
    ?>
    Last edited by ohgod; 07-29-2008 at 04:33 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •