Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

HELP! Drop down menu loaded from database

  • 16-06-2008 08:22PM
    #1
    Closed Accounts Posts: 4


    i'm going doing a property site as a summer project for a client. It would be something like http://www.property.ie/.

    However i need to know how can you create a drop down menu loaded from
    a database. it would also be helpful if someone could also explain how to display info from a database into a HTML table.

    if you can, could someone recommend a website or book.

    i would be using apache, php, mysql


Comments

  • Registered Users, Registered Users 2 Posts: 26,449 ✭✭✭✭Creamy Goodness


    you would do something like this.

    select item from table group by item;

    then start your select drop down list.
    while loop while there are results from the sql statement to display the options
    when the while loop finishes, end your select drop down list.


  • Registered Users, Registered Users 2 Posts: 3,594 ✭✭✭forbairt


    http://devzone.zend.com/public/view/tag/tutorials will have a load of tutorials ...

    Whats your programming background if any ?

    Really it sounds like you are a complete beginner ... as such I'd recommend a book similar to http://www.amazon.com/Web-Database-Applications-PHP-MySQL/dp/0596005431/ref=pd_sim_b_img_5


  • Closed Accounts Posts: 2,046 ✭✭✭democrates


    Also PHP and MYSQL Web Development gives a fair intro.

    A barebones example from a quick google :
    [PHP]
    $connection = mysql_connect("localhost","user","pass");
    $fields = mysql_list_fields("dbname", "table", $connection);
    $columns = mysql_num_fields($fields);
    echo "<form action=page_to_post_to.php method=POST><select name=Field>";
    for ($i = 0; $i < $columns; $i++) {
    echo "<option value=$i>";
    echo mysql_field_name($fields, $i);
    }
    echo "</select></form>";
    [/PHP]Then you'll probably want to use a session variable to track the selected value and use selected="selected" in the option tag.

    Also google for examples of cleansing user input, treat it as toxic by default otherwise you open the application to sql injection attacks.


  • Closed Accounts Posts: 4 jacare


    thanks alot guys.


Advertisement