#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    4
    Rep Power
    0

    How to retrieve the database values to drop down list


    Hi friends i need your help in php programming please tell me how to retrieve the values from database to drop down list and the drop down list consists of multiple selections plzzz reply me soon
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    677
    Rep Power
    7
    If I undertand you correctly... You wish to create a drop-down menu from the selection of items from a table in a database?

    If so, research "how-to php mysql select" to retrieve the items you want. Then, within a while() loop, just echo out the <option ...> for the current row as it goes thru the selected items from the database.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    4
    Rep Power
    0
    Originally Posted by Triple_Nothing
    If I undertand you correctly... You wish to create a drop-down menu from the selection of items from a table in a database?

    If so, research "how-to php mysql select" to retrieve the items you want. Then, within a while() loop, just echo out the <option ...> for the current row as it goes thru the selected items from the database.

    Yes i have done the same thing what u have said to me but the drop down list is not at all apearing its just displaying as a bar but not the drop down list



    can u send me sample code
    The following was the code which i have return:-
    <select multiple>
    <?php
    $sql=mysql_query(query);
    while($row=mysql_fetch_array($sql))
    {

    <option>
    <?php echo $row['value']; ?> </option>
    }?>
    </select>

    plzz send me an example code so that i can understand easily because i have already done all the things which you have sent to me
  6. #4
  7. Old Fart
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2012
    Location
    Chicago
    Posts
    106
    Rep Power
    4
    Why are you trying to format data with PHP which runs on the server. You would have better luck using CSS and Javascript [or better yet Jquery] which run on the client side [browser].
  8. #5
  9. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    Yes i have done the same thing what u have said to me but the drop down list is not at all apearing its just displaying as a bar but not the drop down list
    I don't know what you mean by displaying as a bar, but if you want it to be a dropdown then don't include the "multiple" attribute in your select tag.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    4
    Rep Power
    0
    Originally Posted by E-Oreo
    I don't know what you mean by displaying as a bar, but if you want it to be a dropdown then don't include the "multiple" attribute in your select tag.

    I mean to say that its not displaying in a proper way i have used multiple in select because there should be multiple selections under a single ddl i.e it is a multiple selection ddl
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2005
    Location
    Vancouver, WA, USA
    Posts
    397
    Rep Power
    189
    Originally Posted by Tejasree
    Yes i have done the same thing what u have said to me but the drop down list is not at all apearing its just displaying as a bar but not the drop down list

    plzz send me an example code so that i can understand easily because i have already done all the things which you have sent to me
    So in your browser, now view the source. This will show you what HTML you have created with your PHP. What does that look like? Does it look like HTML dropdown examples you have found?

    (in firefox it's <ctrl>-u )
    Thomas Tremain
  14. #8
  15. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    204
    Rep Power
    3
    PHP Code:
    <select name="values">
    <?php foreach($values as $value) : ?>
    <option><?= $value['name'?></option>
    <?php endforeach ?>
    </select>
  16. #9
  17. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    677
    Rep Power
    7
    Is ur line missing the $?
    PHP Code:
    $sql=mysql_query(query);

    $sql=mysql_query($query); 
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2013
    Posts
    4
    Rep Power
    0
    Originally Posted by notflip
    PHP Code:
    <select name="values">
    <?php foreach($values as $value) : ?>
    <option><?= $value['name'?></option>
    <?php endforeach ?>
    </select>

    thanq i got it

IMN logo majestic logo threadwatch logo seochat tools logo