#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    24
    Rep Power
    0
    Id like to load a drop down list from a mysql database using php3 and create a link to that record. Does anyone have any ideas?
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Location
    Blackstone, VA, USA
    Posts
    5
    Rep Power
    0
    Here is how I did it:
    <SELECT NAME="category">
    <?
    mysql_pconnect("localhost","user","pass") or die ("unable to connect");
    mysql_select_db("yourdb") or die ("cannot select db");
    $opt_sql = "SELECT whatever FROM yourtable";
    $opt_1 = mysql_query($opt_sql);
    while($opt_2 = mysql_fetch_row($opt_1)) {
    echo "<OPTION VALUE="" . $opt_2[0] . "">" . $opt_2[0] . "</OPTION>n";
    }
    mysql_free_result($opt_1);

    ?>
    </SELECT>

    Hope this helps.


    <BLOCKQUOTE><font size="1" face="Verdana,Arial,Helvetica">quote:</font><HR>Originally posted by bbrown:
    Id like to load a drop down list from a mysql database using php3 and create a link to that record. Does anyone have any ideas?[/quote]

  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2000
    Location
    Colombo, Western, Sri Lanka
    Posts
    41
    Rep Power
    15
    What's the n at the end of </option> for??

    echo "<OPTION VALUE="" . $opt_2[0] . "">" . $opt_2[0] . "</OPTION>n";
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Herne Bay, Kent, UK
    Posts
    30
    Rep Power
    15
    they're to insert a newline -- just keeps the generated code tidy

Similar Threads

  1. Mysql problem.
    By Nik in forum MySQL Help
    Replies: 54
    Last Post: December 21st, 2006, 06:02 PM
  2. Upgrade from access to mysql
    By karib1 in forum ASP Programming
    Replies: 7
    Last Post: December 16th, 2003, 12:35 PM
  3. Upgrade from access to mysql
    By karib1 in forum MySQL Help
    Replies: 1
    Last Post: December 16th, 2003, 12:27 AM

IMN logo majestic logo threadwatch logo seochat tools logo