I have a table with folder paths and a button inside each table row. When the button is clicked inside a row, the path gets send to a series of php files (ajax.php, ajax2.php, ajax3.php). After ajax3.php is completed a pdf report is created and pdf_report.php displays the report.
Problem: I can not find a way to display the pdf report inside the row the button was clicked on. When I click 'Run' the pdf report gets displayed on all rows.
My code is the following:
search.php
        <?php
        ...
        while($row = $result->fetch_assoc()){
            $field1name = $row["test_id"];
            $field2name = $row["path"];
            $field3name = $row["video1_path"];
            $field4name = $row["video2_path"];
            $field5name = $row["video3_path"];
            $field6name = $row["video4_path"];
          echo "<tr>
                  <td> ".$field1name." </td>
                  <td> ".$field2name." </td>
                  <td> ".$field3name." </td>
                  <td> ".$field4name." </td>
                  <td> ".$field5name." </td>
                  <td> ".$field6name." </td>
                  <td><div>
                        <button class='edit' id='" . $row['test_id'] . "'>Run</button>
                      </div></td>
                  <td><div class= 'result' id='" . $row['test_id'] . "'>
                    <p></p>
                  </div></td>
                </tr>";
        }
      }else {
        echo '<span style="color:#ff0000;text-align:center;">No Test ID Selected!</span>';
      }
    }
    // Close connection
    mysqli_close($conn);
  ?>
  </table>
</div><br>
<div style="overflow-x:auto;">
<table id=test_data>
  <tr>
    <th>Progress</th>
    <th>Progress Status</th>
  </tr>
  <tr>
    <td><div><progress id='progBar' value='0' max='100'></progress></div></td>
    <td><div><p id='progress-text'></p></div></td>
  </tr>
</table>
</div>
<!--Uses jquery to run 3 scripts and displays it in a progress bar-->
<script>
$(document).on('click', '.edit', function(){
  //set cookie value to 'path'
  var fcookie='mycookie';
  var test_id = $(this).attr('id');
  if(test_id) {
    var path = $(this).closest('tr').find("td:nth-child(2)").text();
  }
  document.cookie='fcookie='+path;
    //Start of 1st script
      $.ajax({
        url: "ajax.php",
        type:"POST",
        success: function(data) {
          //alert("File 1 Completed")
            $("#progress-text").text("Executing file 1");
            $('#progBar').val(25);
            //Start of 2nd script
            $.ajax({
              url: "ajax2.php",
              type:"POST",
                success: function(data2) {
                  //alert("File 2 Completed")
                  $("#progress-text").text("Executing file 2");
                  $('#progBar').val(50);
                  //Start of 3rd script
                  $.ajax({
                    url: "ajax3.php",
                    type:"POST",
                      success: function(data3) {
                        //alert("File 2 Completed")
                         $("#progress-text").text("Complete");
                         $('#progBar').val(100);
                        $(this).closest("tr").find("td:nth-child(8)").load("pdf_report.php");
                      }
                  })
                }
            })
          }
    })
    return false;
   //});
});
</script>
pdf_report.php
...
<style>
.report {
  color: black;
  border: 2px solid #008CBA;
  border-radius: 8px;
}
</style>
<!-- Opens the pdf report in a new tab "_blank" -->
<a href= "<?php echo $path.$pdf; ?>" class="report w3-button" target="_blank">Report</a>
 
    