弹出js对话框onclick表行并显示php信息

I have a php site that displays table information from MySQL DB. I created a js that will pop-up upon clicking the row table. The problem is it will only function on the first row and nothing for the rest of it. And also I wanted to display the captured information from the row where it was clicked to the popup/dialog box. Thank you!

Here's my Table

<tr id="popup" style="cursor: pointer;">
<td hidden="text"><?php echo odbc_result($result,"OBGyneID"); ?></td>
<td><?php echo odbc_result($result,"Lname"); ?>
    , &nbsp;<?php echo odbc_result($result,"Fname"); ?>
    &nbsp;<?php echo odbc_result($result,"mi"); ?></td>
<td class="hidden-ob-xs"><?php echo odbc_result($result,"Bday");?></td>
<td class="hidden-ob-xs"><?php echo odbc_result($result,"pxAge"); ?></td>
<td class="hidden-ob-xs hidden-ob-sm"><?php echo odbc_result($result,"PhoneNum"); ?></td>    
<td><?php  echo odbc_result($result,"service"); ?></td>  
<td class="hidden-ob-xs hidden-ob-sm"><?php echo odbc_result($result,"obgyneTime"); ?></td>                                                  
</tr>

Here's my JS

        $('#popup').click(function(){
            swal({
                title:  'Are you sure you want to delete this record?',
                text: 'You will not be able to recover this record again!',
                type: 'warning',
                showCancelButton: true,
                buttonsStyling: false,
                confirmButtonClass: 'btn btn-danger',
                confirmButtonText: 'Yes, delete it!',
                cancelButtonClass: 'btn btn-light',
                background: 'rgba(0, 0, 0, 0.96)'
            }).then(function(){
                swal({
                    title: 'Are you sure?',
                    text: 'You will not be able to recover this imaginary file!',
                    type: 'success',
                    buttonsStyling: false,
                    confirmButtonClass: 'btn btn-light',
                    background: 'rgba(0, 0, 0, 0.96)'
                });
            });
        });

add class on TR tag

<tr class="popup" data-company="Google" style="cursor: pointer;">

change this class to call popup

 $('.popup').click(function(){

    var company = $(this).data('company');

     /* your code */

 });

Check below code. I hope it will help you.

$('.test').on('click', function(){
    // this is your table id
    var dataId = $(this).attr('data-id');
  swal({
    title:  'Are you sure you want to delete this record?',
    text: 'You will not be able to recover this record again!',
    type: 'warning',
    showCancelButton: true,
    buttonsStyling: false,
    confirmButtonClass: 'btn btn-danger',
    confirmButtonText: 'Yes, delete it!',
    cancelButtonClass: 'btn btn-light',
    background: 'rgba(0, 0, 0, 0.96)'
  }).then(function(){
    // Add your ajax code here
    swal({
      title: 'Success',
      text: 'Record Deleted Suucessfully',
      type: 'success',
      buttonsStyling: false,
      confirmButtonClass: 'btn btn-light',
      background: 'rgba(0, 0, 0, 0.96)'
    });
  });
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"></script>
<table border="1">
  <tr class="test" data-id="1"> <!-- Pass your table id into data-id -->
    <td>Testing</td>
    <td>Testing</td>
    <td>Testing</td>
    <td>Testing</td>
    <td>Testing</td>
  </tr>
  <tr class="test" data-id="2">
    <td>Testing1</td>
    <td>Testing1</td>
    <td>Testing1</td>
    <td>Testing1</td>
    <td>Testing1</td>
  </tr>
  <tr class="test" data-id="3">
    <td>Testing2</td>
    <td>Testing2</td>
    <td>Testing2</td>
    <td>Testing2</td>
    <td>Testing2</td>
  </tr>
</table>

</div>

I think you are trying to delete a record. So below code may be useful. You may have to pass your record id to be deleted in future The #id variable must be unique for each row. Try below code

HTML

 <tr onclick="myFunction( <?php print $recid; ?> )"> <tr>

JS

  myFunction(recid){
      swal({
        title: "Are you sure you want to delete this record?",
        text: "Once deleted, you will not be able to recover this record !",
        icon: "warning",
        buttons: true,
        dangerMode: true,
        closeOnClickOutside: false,
        closeOnEsc: false
    })
    .then((willDelete) => {
        if(willDelete) {

          // Here make a POST request to delete your record using recid paramter

        } else {
            // do nothing
        }
    });
 }

Feel free to ask doubts. Please vote/mark this answer if it's helpful.