title: I can't post data from an html table generated by a loop to extract from a database and going into a new page
body: <p>I have a loop to populate a html table with available produce. At the end of each row I have a button so the user can select the row. But the data doesn't appear in the next page</p>
  
  <p>I have tried all sorts of advice from this and other sites, but I haven't seen anything using a loop to extract the data, and nothing has worked. (But I have only been learning for 5 weeks...)</p>
  
  <pre><code>         &lt;table class="table table-bordered" id="dataTable" width="100%" 
     cellspacing="0"&gt;
              &lt;thead&gt;               
          &lt;tr&gt;
                  &lt;th&gt;Load Ref&lt;/th&gt;
                  &lt;th&gt;Load Time&lt;/th&gt;
                  &lt;th&gt;Del Time&lt;/th&gt;
                  &lt;th&gt;From&lt;/th&gt;
                  &lt;th&gt;To&lt;/th&gt;
          &lt;th&gt;Price&lt;/th&gt;
          &lt;th&gt;Accept&lt;/th&gt;
  
                &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tfoot&gt;
                &lt;tr&gt;
                  &lt;th&gt;Load Ref&lt;/th&gt;
                  &lt;th&gt;Load Time&lt;/th&gt;
                  &lt;th&gt;Del Time&lt;/th&gt;
                  &lt;th&gt;From&lt;/th&gt;
                  &lt;th&gt;To&lt;/th&gt;
          &lt;th&gt;Price&lt;/th&gt;
          &lt;th&gt;Accept&lt;/th&gt;
                &lt;/tr&gt;
              &lt;/tfoot&gt;
              &lt;tbody&gt;
  
    &lt;?php
  
     $sql = "SELECT  loadID, loadTime, tipTime, town_city, delTownCity, 
    loadPrice FROM `loads` WHERE town_city = '$startpoint'";
  
    $retval = mysqli_query( $con, $sql);
  
    if(!$retval ) {
    die("Could not get data: ". mysqli_connect_errno());
     }
  
     while($row = mysqli_fetch_array($retval)) {
  
     echo "&lt;tr&gt;&lt;td&gt;$row[0]&lt;/td&gt;".
       "&lt;td&gt;$row[1]&lt;/td&gt; ".
       "&lt;td&gt;$row[2]&lt;/td&gt; ".
       "&lt;td&gt;$row[3]&lt;/td&gt; ".
       "&lt;td&gt;$row[4]&lt;/td&gt; ".
       "&lt;td&gt;$row[5]&lt;/td&gt; ";
       Echo '&lt;td&gt;&lt;input type = "button" class="btn btn-primary btn-block" 
       value = "Accept" &gt;&lt;/td&gt;&lt;/tr&gt;';
  
  
    }
  
    echo "Fetched data successfully\n";
  
    mysqli_close($con);
  
   ?&gt;
     &lt;script src = "js/jquery.min.js"&gt;&lt;/script&gt;
     &lt;script&gt;
  
  
  
     $('.table tbody').on('click','.btn',function(){
     var currow = $(this).closest('tr');
     var col1 = currow.find('td:eq(0)').text();
     var col2 = currow.find('td:eq(1)').text();
     var col3 = currow.find('td:eq(2)').text();
     var col4 = currow.find('td:eq(3)').text();
     var col5 = currow.find('td:eq(4)').text();
     var col6 = currow.find('td:eq(5)').text();
     var result = col1+'\n'+col2+'\n'+col3+'\n'+col4+'\n'+col5+'\n'+col6;
  
  
     console.log(result);
     $.ajax({
           type: "POST",
           url: "accept.php",
           data: 'result'
             });
                alert(result);
                window.location.href ="accept.php";
            })
  
           &lt;/script&gt;
  </code></pre>
  
  <p>I just need to see the data in the new page "accept.php". it shows in the console on the first page, but then everything is empty in the second page.</p>