Something like this should work:

  after mysql_connect() and mysql_select_db() ...
  $sql = "SELECT color_id,color FROM mytable";
  $result = mysql_query($sql);
  echo '<form blah,blah,blah>';
  echo '<select name="color_id">';
  while ($row = mysql_fetch_array($result)){
    printf("<option value=\"%s\">",$row["color_id"]);
  echo '</select>';
  echo '</form>';


- E

Check the manual for printf() if you're not sure how it works...

>I want to pull information out of my mySQL database and use it as a pull
>down menu ona web page.  There are two sets of information that I need, 
>is a color, and the other is the color_id, so I want to use it in the way
>below but without having to physically enter all the data.  I'd like to 
>color_id as the value and the actual color name as the text in the pull 
>button.  Can someone please help me on how to pass the info into a useable
>way to get the info out of PHP and into HTML?  I've haad no problems going
>from HTML to PHP, but can't seem to grasp going the other way, especially
>with a list of things.  I've been banging my head against this for two 
>but something tells me it's extremely easy.
><form name="tester" action="script.php" method="get">
>  <select name="color">
>   <option value="1">red
>   <option value="2">blue
>   <option value="3">black
>   <option value="4">ice
>   <option value="5">purple
>  </select>
>PHP General Mailing List (
>To unsubscribe, visit:

きっと見つかるあなたの新居 不動産情報は MSN 住宅で

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to