Jump to content

value of option menu not showing.


unistake

Recommended Posts

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

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.

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>";
                    ?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.