unistake Posted October 21, 2010 Share Posted October 21, 2010 Something is wrong with this drop down form menu. The name of the option appears and works well however the value does not seem to work. Any ideas? Thanks <?php include("cxn.php"); $query = "SELECT manufacturer FROM list ORDER BY manufacturer ASC"; $result = mysqli_query($cxn,$query) or die(mysqli_error()); ?> <select name="manufacturer" id="manufacturer"> <option value="" selected="selected">Select a Manufacturer..</option>"; <?php while($row = mysqli_fetch_row($result)){ echo "<option value=\"".$row[0]."\">".$row[0]."</option>"; // SHOWS ALL MANUFACTURERS CURRENTLY ADVERTISED WITH THE NUMBER OF ADVERTS NEXT TO THE MANUFACTURER } ?> Link to comment https://forums.phpfreaks.com/topic/216509-value-of-option-menu-not-showing/ Share on other sites More sharing options...
benji_182 Posted October 21, 2010 Share Posted October 21, 2010 Hmmm, personally I'd try it like this. <?php include("cxn.php"); $query = "SELECT manufacturer FROM list ORDER BY manufacturer ASC"; $result = mysqli_query($cxn,$query) or die(mysqli_error()); ?> <select name="manufacturer" id="manufacturer"> <option value="" selected="selected">Select a Manufacturer..</option>"; <?php while ($row = mysqli_fetch_row($result)) { echo "<option value=\"{$row["fieldname1"]}\">{$row["fieldname2"]}</option>"; } ?> </select> Hope this helps. Link to comment https://forums.phpfreaks.com/topic/216509-value-of-option-menu-not-showing/#findComment-1125004 Share on other sites More sharing options...
Colton.Wagner Posted October 21, 2010 Share Posted October 21, 2010 You did not echo the <select> tag or the first <option> or the closing </select> tag. Revised code: <?php include("cxn.php"); $query = "SELECT manufacturer FROM list ORDER BY manufacturer ASC"; $result = mysqli_query($cxn,$query) or die(mysqli_error()); echo "<select name=\"manufacturer\" id=\"manufacturer\">"; echo "<option value=\"\" selected=\"selected\">Select a Manufacturer..</option>"; while($row = mysqli_fetch_row($result)){ echo "<option value=\"".$row[0]."\">".$row[0]."</option>"; // SHOWS ALL MANUFACTURERS CURRENTLY ADVERTISED WITH THE NUMBER OF ADVERTS NEXT TO THE MANUFACTURER } echo "</select>"; ?> Link to comment https://forums.phpfreaks.com/topic/216509-value-of-option-menu-not-showing/#findComment-1125007 Share on other sites More sharing options...
unistake Posted October 21, 2010 Author Share Posted October 21, 2010 they are there in between the two php scripts. (in black above) Link to comment https://forums.phpfreaks.com/topic/216509-value-of-option-menu-not-showing/#findComment-1125013 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.