On your first block of code above, this is wrong:
<tr id="data">...</tr>
If your query yields three records you will see the same id three times:
<tr id="data">...
<tr id="data">...
<tr id="data">...</tr>
You are NOT allowed to have an id multiple times. It MUST be unique throughout the page. My suggestion would be to append the record id prefixed with an underscore - ex:
<tr id="data_1">...
<tr id="data_12">...
<tr id="data_34">...</tr> On your second block of code above, on lines 9-16, you do NOT need any php code. On your first code of block you are generating an HTML table. Each Row of that table corresponds to one record in your db. So if you click on Edit of the Third row, you do NOT need to send a request to the server to find out what the data for that record is. You already have it on the browser (in your HTML table!). All you need to do is Extract the data from each of the cells in the relevant row. If you incorporate the edits I suggested above, you can extract the id from the <TR> element.
Thus, there really is no need for the id in <a href="?id=X">Edit</a> .
As for your popup.txt file, it currently has: $("#popup").click(function(){...});
Instead, use:
$(".popup").bind('click',function(){
//find the parent row of the clicked "Edit"
var row= $(this).closest("tr");
//"extract" the id from row
var id =row.attr('id').split('_')[1];
//find the hidden field in your edit form and assign the id
$('#ud_id').val(id);
//iterate through each table cell and extract the innerHTML
//and assign it to the corresponding field in your edit form
//NOTE: this requires that each cell in your Table has a
//class="FIELD_ID" - ex:
/*
<tr id="data_1"><td class="ud_name">Google</td><td class="ud_code">a</td><td class="ud_account">123</td><td class="ud_phone">855-999-9999</td><td class="ud_username">alpha</td><td class="ud_password">Password</td><td class="ud_web">v</td><td><a class="popup" href='#'>[Edit]</a></td></tr>
Thus in your edit form you will need a field with
id="ud_name"
AND one with id="ud_code"
AND one with id="ud_account"
etc.
Also notice that the Edit link now has class="popup" since your jquery changed from:
$('#popup')
to:
$('.popup')
*/
$('td:not(:last)',row).each(function(){
$('#'+this.className).val(this.innerHTML);
});
//centering with css
centerPopup();
//load popup
loadPopup();
return false;
});