如何使用表值来使用PHP驱动mySQL查询

I have a HTML table that is populated directly from a bit of PHP that pulls data in from a mySQL table.

I have the table set up so each row can be clicked to load a modal containing a form to allow data to be updated and submitted back to the database using a mysql update query.

The problem I have is passing the HTML table row ID back into my PHP select to return the 1 table row that has been clicked.

As I am using a row click to launch the modal, I don't want to use a form submit option to trigger to POST a variable?

Any ideas how I could do this?

Thanks

You can write the row ID in a html attribute and use JS to read it from there.

Sample html:

<tr row_id="1234"></tr>

Sample JS (jQuery):

jQuery("tr").click(function(e) {
  var row_id = jQuery(e.currentTarget).attr("row_id");
});