Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2003
    Posts
    2

    Unanswered: PHP combo(select) boxes

    Hey, I've been using MYSQL and PHP for about 2 weeks now, getting somewhat proficcient.

    I am working on a database insertion form, and would like to create a combo/select box from one of my data base tables.

    I am using PHP to connect to my database, and know how to perform queries, I am just getting confused as to how to populate my combo box with values from an already built table ("resolutions").

    If anyone could send me in the right direction, or had any links to tutorials i would greatly appreciate it.

    - Dave The Noobie

  2. #2
    Join Date
    Apr 2003
    Posts
    2

    too slow

    figured it out-
    if anyone is interested here it is:

    /* CONNECT TO MYSQL DATABASE OR DIE AND TELL WHY*/

    $link = mysql_connect("localhost", "user", "pass")
    or die("Could not connect: " . mysql_error());
    print ("Connected successfully");
    mysql_select_db("my_db") or die("Could not select database");




    /* TEXT FORMATTING */
    print "<pre>";

    /* Performing SQL query */
    $query = "SELECT * FROM my_table";
    $result = mysql_query($query) or die("Query failed");
    print "<select name=reso>\n";
    /* Printing results in HTML */
    while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {

    foreach ($line as $col_value) {}
    print "<option>$col_value\n";
    }
    print "</select>\n"


    ?>

Posting Permissions

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