title: Pass HTML Select into PHP Variable
body: <p>I have several select statements that look like this. I need to pass the php variable into my database.    </p>
  
  <pre><code> &lt;select name="gamestart" &gt;
   &lt;?php for($gamestart=1; $gamestart&lt;=24; $gamestart++)
   echo "&lt;option value='$gamestart'&gt;$gamestart:00&lt;/option&gt;"; 
   ?&gt;
   &lt;/select&gt;
  </code></pre>
  
  <p>Here is my insert statement into my database with other similar variables where I have the same issue. </p>
  
  <pre><code>     &lt;?php 
     $mysql_query = "INSERT INTO soccer_games (gamestart, gameend)
          VALUES ('$gamestart', '$gameend')";
  
      $this-&gt;db-&gt;query($mysql_query);
     ?&gt;
  </code></pre>
  
  <p>As of now, values are being put into the database but the value that is INSERT'ed into the database is the number 25 (not even an option in my loop as you can see) regardless of what value I select in the form. </p>
  
  <h1>===============</h1>
  
  <p>EDIT 1:
  The problem would probably be that I haven't used a form (Me in my infinite wisdom didn't realize I needed a form for this).</p>
  
  <p>I am assuming I will need something of this nature...</p>
  
  <pre><code>public function insertstatements(){
  &lt;?php 
     $mysql_query = "INSERT INTO soccer_games (gamestart, gameend)
          VALUES ('$gamestart', '$gameend')";
  
      $this-&gt;db-&gt;query($mysql_query);
     ?&gt;
  }
  
  
  &lt;form method="post" action="&lt;?php insertstatements(); ?&gt;"&gt;
  
  
   &lt;select name="gamestart" &gt;
   &lt;?php for($gamestart=1; $gamestart&lt;=24; $gamestart++)
   echo "&lt;option value='$gamestart'&gt;$gamestart:00&lt;/option&gt;"; 
   ?&gt;
   &lt;/select&gt;
  &lt;/form&gt;
  </code></pre>