title: How to submit a dynamic dropdown list with php in a table (tr,td)
body: <p>I have a question, apparently I was able to do a dropdown list where I was able to retrieve the values from MYSQL, however, now I want it to insert into a new query, below 2 codes contains how I place my dropdown list, and the other codes would be how I insert and submit the data. So my question is how do i submit the sbranch_name from the dropdown list to the next page in order for me to post it?</p>
  
  <pre><code>&lt;form action="processstaffb.php" method="post"&gt;
      &lt;table id="t01"&gt;
          &lt;h2&gt; Add Staff User &lt;/h2&gt;
          &lt;tr&gt;
              &lt;th width="1%"&gt;Branch&lt;/th&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td width="1%"&gt;
                  &lt;?php
                  session_start();
                  $mysqli = new mysqli(spf, dbuser, dbpw, db);
                  $sql="Select sbranch_name from branches";
                  $result = $mysqli-&gt;query($sql);
                  if ($result-&gt;num_rows &gt; 0) {
                      echo "&lt;select name1='sbranch_name'&gt;";
                      while($row = $result-&gt;fetch_assoc()) {
                          echo "&lt;option value='" . $row['sbranch_name'] . "'&gt;" . $row['sbranch_name'] . "&lt;/option&gt;";
                      }
                      echo "&lt;/select&gt;";
                  }
                  $mysqli-&gt;close();
                  ?&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
  
      &lt;/table&gt;
  
      &lt;br&gt;
      &lt;br&gt;
      &lt;input type="submit" id="button2" name="submit" value="Add staff" /&gt;
      &lt;input type="reset" id="button2" value="Clear"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>codes for i am sending through to the next page,</p>
  
  <pre><code>    if (!empty($_POST['sbranch_name'])) 
  {
     $sbranch_name =$_POST["sbranch_name"];
  }
  else 
  { 
     $sbranch_name = null;
     echo '&lt;p&gt;&lt;font color="red"&gt;You forgot to enter the branch of the officer!&lt;/font&gt;&lt;/p&gt;';
      // testing whether i have managed to bring over.
      echo "$name1";
      echo "$sbranch_name";
  
  }
  
  if ($sbranch_name)
  {
  
  $mysqli = new mysqli(spf, dbuser, dbpw, db); 
  $stmt = $mysqli-&gt;prepare("INSERT INTO staffbranch 
  (sbranch_name) 
  VALUES (?)");
  $stmt-&gt;bind_param("s", $sbranch_name);
  $result = $stmt-&gt;execute();
  
  if ($result == true &amp;&amp; $stmt-&gt;affected_rows&gt;0) {        
  
       echo "&lt;b&gt;". $check . "&lt;/b&gt;&lt;br&gt;";
  
   }
   else
   {
       echo '&lt;p&gt;Please &lt;a href="addstaffb.php"&gt;Click Here&lt;/a&gt; to return&lt;/p&gt;'; 
  
   }
  $stmt-&gt;fetch(); 
  $stmt-&gt;close();
  $mysqli-&gt;close();   
  }
  else 
  {
  echo '&lt;p&gt;Please &lt;a href="addstaffb.php"&gt;Click Here&lt;/a&gt; to return&lt;/p&gt;';  
  }
  </code></pre>