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 5 of 5
  1. #1
    Regular Coder
    Join Date
    Jul 2008
    Location
    Blackpool, UK
    Posts
    176
    Thanks
    4
    Thanked 0 Times in 0 Posts

    PHP Help with Drop Down Menu

    Hi

    I am fairly new to PHP and am having trouble with one issue.


    Basically I have a drop down menu with 3 categories which are setup in a table call

    portfolio_cat:

    the categories have an ID of 1,2 and 3. There will be no more going into this table.

    Basically our old programmer created the other part of this form and I am adding this category drop down to it.

    His table called portfolio had the following in it

    id
    jobtitle
    customer
    location
    info
    testimonial
    image1
    image2
    image3

    What I need to do is set up the form so that when the client is creating the portfolio they can select which category that information is based on.

    Ie portfolio on windows

    All the info in the portfolio table will be linked to the portfolio_cat table ID 1.


    How do i do this??


    Any help would be great.


    Danny
    NEWBIE PROGRAMMER

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    My first instinct is to add a column portfolio_cat to your portfolio table.

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


    I initially thought that. But my boss said I needed to have the categories in a different table with the ID and the category.

    There will only ever be 3 categories. Doors, Conservatories and Windows.


    The client would select which category the portfolio was going under.

    IE they have done a job installing windows, they would select windows in the drop down, then fill in the relevant details.

    If i added a category row in the portfolio table, what would be the php code in the form be to recognise which category was selected?

    The php script for this page done by the previous programmer is huge, but if you need me to post it to help you more i will.


    Cheers

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    No I don't need the code... the value from a form comes across via the $_POST or $_GET arrays, including the value from a form's <select> element. If this is an unfamiliar concept to you, run through some tutorials and read the PHP manual on how forms are processed.

    http://us.php.net/manual/en/tutorial.forms.php

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


    I think I am getting grips with the $_POST[] thing.

    So if I add a row in the portfolio table called categories

    inside that there will be

    windows
    doors
    conservatories

    Then in the form i would put the value as "windows" "doors" "conservatories"


    Then in the PHP i would have

    PHP Code:
    $windows $_POST['windows']; 
    While the other part of the form is inserting into the database.
    Would I do a query to SELECT the value from the categories row???


    Any help on the query section or this part would be great. I am reading through a book at the moment, and am not yet up to this part, or should I say the examples in the book do not cover drop down menus which leaves me in a pickle.


    If anybody could help with the building blocks I feel I would find it easier to learn and understand.



    Cheers


    Dan


  •  

    Posting Permissions

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