0

I am working on a PHP code in which when page is run it will display dynamic records with an option of Update button. Now the problem is that it is generated dynamically, so how do I get particular COLUMN value of table record when a button is clicked?

4

1 に答える 1

0

テーブルを作成するPHP

    echo "<table>";
    echo "<tr>";

    while( ($row = mysql_fetch_array($result)))
    {
        echo "<td>".$row['no']."</td>";
        echo "<td>".$row['notify']."</td>";
        echo "<td>".$row['date']."</td>";
        echo "<td>".$row['url']."</td>";
        echo "<td><input type='button' name='update' onClick='updateRecord(this)' id='update' value='".$row['id']."'></td>";
    }

    echo "</tr>";
    echo "</table>";

レコードを更新する JavaScript

function updateRecord(id)
{
    var recordId = id.value;
     ...Update record through ajax call...
     ...Update record through form submit...

}

ajax 呼び出しによるレコードの更新

$.ajax({
        url: 'update.php',
        method: 'GET',
        data: 'userID=' + recordId,
        success: function(new_data){
             $(popID).html(new_data);
              $(popID).dialog();
              alert('Load was performed.');
        }
    });
于 2012-12-27T18:26:37.193 に答える