title: PHP Passing single table row data and date input field using PHP using $_post
body: <p>I am currently working on an application that was built some time ago, unsure of the framework.</p>
  <p>It has a function that when called, generates table rows with the ID for each run. I have added a Date field on the page which I also want to pass along with the tr input id for which the submit is pressed.</p>
  <pre><code>function run($db)
  {
      $select = &quot;&quot;;
  
      $sql = &quot;SELECT * FROM `run1`&quot;;
  
      $db-&gt;query($sql);
  
      if ($db-&gt;num_rows()) {
  
          while ($rec = $db-&gt;fetch_assoc()) {
              $id = $rec['run1_id'];
              $name = $rec['run1_name'];
  
  
  
              $select .= &quot;&lt;tr&gt;
                              &lt;td&gt;&lt;input type='text' id='rowid' name='rowid' value='$id' form='runcountform' hidden&gt;$name&lt;/td&gt;
                              &lt;td&gt;&lt;input class='btn btn-primary' type='submit' value='Enter Run' form='runcountform'&gt;&lt;/td&gt;
                          &lt;/tr&gt;&quot;;
          }
      }
      return $select;
  }
  </code></pre>
  <p>Currently, I have a form tag that I append the tr to using the form=&quot;&quot; attribute, this however only sends the id of the last table row in the table, not the specific row that is clicked.</p>
  <p>i.e. If I have 10 rows and the button on row 2 is clicked I get the value from the 10th row not the second.</p>
  <pre><code>&lt;body&gt;
      &lt;div class=&quot;container&quot;&gt;
          &lt;form id=&quot;runcountform&quot; method=&quot;post&quot; action=&quot;__SITE_URL__/run_sheet.php&quot;&gt;&lt;/form&gt;
          &lt;div class=&quot;d-flex mt-4&quot;&gt;
              &lt;div class=&quot;&quot;&gt;
                  &lt;h3&gt;Enter Run Sheet&lt;/h3&gt;
              &lt;/div&gt;
              &lt;hr&gt;
              &lt;div class=&quot;ml-auto p-2&quot;&gt;&lt;a href=&quot;__SITE_URL__/production.php&quot; class=&quot;btn btn-primary&quot;&gt;Cancel&lt;/a&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;row&quot;&gt;
              &lt;div class=&quot;col&quot;&gt;
                  __PROMPT__
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class=&quot;row mb-4 mt-2&quot;&gt;
              &lt;div class=&quot;col-6&quot;&gt;
                  &lt;select class=&quot;form-control&quot; name=&quot;day_select&quot; id=&quot;day_select&quot; form=&quot;runcountform&quot; required&gt;
                      &lt;option value=&quot;&quot;&gt;Select Day&lt;/option&gt;
                      &lt;option value=&quot;2&quot;&gt;Monday&lt;/option&gt;
                      &lt;option value=&quot;3&quot;&gt;Tuesday&lt;/option&gt;
                      &lt;option value=&quot;4&quot;&gt;Wednesday&lt;/option&gt;
                      &lt;option value=&quot;5&quot;&gt;Thursday&lt;/option&gt;
                      &lt;option value=&quot;6&quot;&gt;Friday&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;table class=&quot;table table-bordered table-striped&quot;&gt;
              &lt;thead class=&quot;thead-light&quot;&gt;
                  &lt;tr&gt;
                      &lt;th&gt;Run&lt;/th&gt;
                      &lt;th&gt;Action&lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tbody&gt;
                  __run__
              &lt;/tbody&gt;
          &lt;/table&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  </code></pre>
  <p>Not very experienced in this, so any help is appreciated.</p>