通过jquery编辑数据库条目

This query gives me a list from the database

while($res=mysql_fetch_array($temp)){                   
    echo "<tr>";
    echo "<td id='copyme'>".$res['name']."</td>";
    echo "<td><a href=''>Edit</a></td>";                        
}
echo "</tr>";

By clicking the edit i want the name to be written in this input box so i can update or delete it, the sql update query works once the name is on the box, my only problem is to get the name there once i click edit.

 <label>Template name:</label> <input id="temp_edit" type="text" name="tempname" />

How can id do this via jquery? or is there a better way?

Use copyme as a class, not an id because you will be having more than one of that element if you have a list from database, then try this:

$('#yourTable').on('click', 'a', function(){
    var copyValue = $('.copyme', $(this).closest('tr')).text();
    $('#temp_edit').val(copyValue);
});