Jump to content


Photo

Pulling a drop down list from a product table


  • Please log in to reply
1 reply to this topic

#1 tomfmason

tomfmason
  • Staff Alumni
  • Advanced Member
  • 1,696 posts
  • Locationstealing your wifi

Posted 16 June 2006 - 03:04 PM

I am wondering how I can print product names, from a product table, into a drop down menu? Any suggestions would be greatly apperciated.

Traveling East in search of instruction, and West to propagate the knowledge I have had gained.

current projects: pokersource

My Blog | My Pastebin | PHP Validation class | Backtrack linux


#2 freakus_maximus

freakus_maximus
  • Members
  • PipPipPip
  • Advanced Member
  • 177 posts

Posted 16 June 2006 - 03:35 PM

Making some assumptions about your table name and column names in your db, this should do it.


<select id="productnames" NAME="productnames">
<?
$result = mysql_query ("SELECT productnames FROM producttable")
  or die ("Query failed");
while($row=mysql_fetch_array($result)){ 
    echo '<option value="' . $row['productname'] . '">' . $row['productname'] . "</option>\n";
}
?>
</select></P></TD>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users