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
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.

Link to comment
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.