Your problem is here:
$result = mysql_query("SELECT supplier FROM supplier"); while($row = mysql_fetch_array($result)) { /*echo '<form action="">';*/ echo "<select name='supplier'>"; echo "<option value = '$row[supplier]'>""</option>"; echo "</select>";
A Select list is created inside the mysql data loop. As @Hitesh explained. You need to create this outside the loop and only discard the results of the data inside. For instance:
$result = mysql_query("SELECT supplier FROM supplier"); echo "<select name='supplier'>"; while($row = mysql_fetch_array($result)) { echo "<option value=".$row['supplier'].">".$row['supplier']."</option>"; } echo "</select>";
This will exit your drop-down list with all your provider names as the value and the displayed text options.
If you tried to do the following:
$result = mysql_query("SELECT supplier FROM supplier"); while($row = mysql_fetch_array($result)) { /*echo '<form action="">';*/ echo "<select name='supplier'>"; echo "<option value = '$row[supplier]'>""</option>"; echo "</select>"; }
As a result, you will have as many drop-down boxes as you had suppliers in your database. This is because you create a new Select for each record found.
In addition, without specifying a second $row['supplier'] between the option tags, you simply get an empty (empty) drop-down box.
Hope this helps.
source share