title: HTML Option Tags inside PHP Code
body: <p>I'm rather new to PHP (just picked it up for a course on CS) and I'm right now trying to display some values from a Database, namely stocks. Right now I'm running into some issue though as I'm trying to display the stocks symbol from the database in a nice option menu. But when I try to retrieve the value via $_POST["stock"] ("stock" is the name of the option) it displays me an error of "Undefinex index: stock".</p>
  
  <p>Now if I choose the above option (the option before the php code) it actually works perfectly and "stock" is retrievable (and displays nothing, as anticipated). </p>
  
  <p>Now my question is: What did I do wrong and how can I make the name "stock" show the value of $_POST["stock"]</p>
  
  <pre><code>    &lt;select class="form-group"&gt;
      &lt;option class='form-control' type='text' name='stock'&gt;&lt;/option&gt;
      &lt;?php
          $rows = query("SELECT * FROM stocks WHERE id = ?", $_SESSION["id"]);
  
          foreach ($rows as $row)
          {
              print("&lt;option class='form-control' name='stock'&gt;{$row["symbol"]}&lt;/option&gt;");
  
          }
      ?&gt; 
      &lt;/select&gt;   
  </code></pre>