Using On Click ‘Popup’ function with an Anchor Tag for Updating Data in Page as well as Database

I was facing the problem of Updating Data in Database with PHP.

My Code for the above is:

<tbody>
     <?php
     $i = 1;
     if ($num = mysqli_num_rows($result) > 0) {
         while ($row = mysqli_fetch_assoc($result)) {
             echo "
             <tr>
             <td>" . $i++ . "</td>
             <td>" . $row['course_name'] . "</td>
             <td>" . $row['semester'] . "</td>
             <td>
             **<a href='javascript:?$index=$row[srno]&cn=$row[course_name]&sems=$row[semester]' onclick='openEditPopup()'>
             <button class='edit-btn' ><i class='fa-solid fa-pen-to-square'></i> Edit</button>
             </a>**
             <a href='course.php?srno=" . $row['srno'] . "'><button class='dlt-btn' name='deleteCourse'><i class='fa-solid fa-trash'></i> Delete</button></a>
             </td>
             </tr>
             ";
         }
     }
     ?>
</tbody>

I want My popup to be opened where i can edit and it should be on the page itself while fetching details in the input tag of the popup so as to edit.

But Either Popup works by the above Code OR only Values i.e. index, cn and sems get fetched without opening the popup if i use this line:

**<a href='course.php?$index=$row[srno]&cn=$row[course_name]&sems=$row[semester]' onclick='openEditPopup()'>
  <button class='edit-btn' ><i class='fa-solid fa-pen-to-square'></i> Edit</button>
  </a>**

What is the Soln for this?

I tried watching tutorials and reading articles of using on click with anchor tag but none of them worked as i have that Popup Code where i want to edit.