title: How to Populate Dropdown List's text and value from MySQL?
body: <p>I am using mysqli to query a database table to obtain the value for a dropdownlist.  However, I also want to retrieve the corresponding description and load that into the option text.  My query is as follows:</p>
  
  <pre><code>&lt;?php 
  $query=('SELECT restaurantid,location from restaurant');
  $result = mysqli_query($mysqli,$query);
  echo '&lt;select name="ddlStore"&gt;';
  while($row=$mysqli-&gt;fetch_array($result))
  {
      echo '&lt;option value="' . htmlspecialchars($row['restaurantid']) . '"&gt;';
      '&lt;/option&gt;';
  }
  echo '&lt;/select&gt;';
  ?&gt;
  </code></pre>
  
  <p>How do I revise the above so that the location field is populating in the dropdownlist's option text?</p>
  
  <p>Updated code:</p>
  
  <pre><code>&lt;?php 
  $query=('SELECT restaurantid,location from restaurant');
  $result = mysqli_query($mysqli,$query);
  echo '&lt;select name="ddlStore"&gt;';
  while($row=$mysqli-&gt;fetch_array($result))
  {
      echo '&lt;option value="' . htmlspecialchars($row['restaurantid']) . '"&gt;' .
       htmlspecialchars($row['location']) . 
      '&lt;/option&gt;';
  }
  echo '&lt;/select&gt;';
  ?&gt;
  </code></pre>
  
  <p>The above still does not display the locations as dropdownlist option text values.  </p>
  
  <p>Update #2:
  When viewing the page, the dropdownlist doesn't show the values from the database table.  Using IE Developer Tools, I see a script error in the while statement:</p>
  
  <pre><code>Call to undefined method mysqli::fetch_array()
  </code></pre>
  
  <p>Is there a more optimal way to structure the mysqli_fetch_array statement?</p>