title: How to create select option from database?
body: <p>I'm working on a form that has 4 different select elements from 2 tables of a database. I haven't done anything like this and I don't really know how to do it.</p>
  
  <p>I have a table called "students" from I need "name" and "class" and a table called "books" from I need "writer" "title" ... all is one select element and all has more than 2 option values.</p>
  
  <p>I've tried with only one sql query and one select but it shows only one option on the site, wether it has about 6 values in the database.</p>
  
  <p>My code:</p>
  
  <pre><code>$sql = "SELECT class
          FROM students";
  $result = mysql_query($sql);
  
  
  while ($row = mysql_fetch_assoc($result)) {
      $select_class = "&lt;option value={$row['class']}&gt;{$row['class']}&lt;/option&gt;";
  }
  
  &lt;select id="class" name="class"&gt;
      &lt;?php print $select_class; ?&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>How would it be correct?</p>