How to retrieve a selected value from drop-down list ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LadyA
    New Member
    • Dec 2012
    • 1

    How to retrieve a selected value from drop-down list ?

    hi every body
    I am working on web project and I want a simple code

    I have made a drop down list in my HTML
    and I want to save the selected value in a PHP variable
    so I can insert it to my database is this is the correct way?


    Code:
    category <select  name="category_type"  > 
    <option <?php if ($_POST['selectbox'] == 'Networks') echo '$selected="Networks"';?>> Networks</option>
     <option <?php if ($_POST['selectbox'] == 'Securty&systems') echo '$selected="Securty&systems"';?>>Securty&systems </option> 
    <option <?php if ($_POST['selectbox'] == 'Software Develpments') echo '$selected="Software Develpments"';?>>Software Develpments</option> 
    <option <?php if ($_POST['selectbox'] == 'Web&information') echo '$selected="Web&information"';?>>Web&information </option> </select> </br>

    I cant use post because i don't have a database with category values
    please help me with any method in HTML or PHP
    that retrieve a selected value from drop-down list
    Last edited by Rabbit; Dec 14 '12, 04:39 PM. Reason: Please use code tags when posting code.
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    Please use code tags when posting code.

    You question is unclear and vague so I don't know what it is you're actually trying to do.

    But when you say:
    I cant use post because i don't have a database with category values
    That makes no sense because POST and GET have nothing to do with databases. They are merely a way of passing information from page to page.

    Comment

    Working...