Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

HELP! Drop down menu loaded from database

  • 16-06-2008 8: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,584 ✭✭✭✭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