我有如下表格视图
<table>
<tr><th>Username</th>
<th>Departemen</th><th>Created By</th><th>Created Date</th><th>Last Update By</th><th>Last Update Date</th><th>Aksi</th></tr>
<?php
$sql = "SELECT TOP 20 * FROM tblMstUser where CompanyDeptID ='11' or CompanyDeptID ='12' order by LoginID";
$tampil = mssql_query($sql) ;
while($r=mssql_fetch_array($tampil)){
echo "<tr><td>$r[LoginID]</td>
<td>$r[LoginName]</td>
<td>$r[CreatedBy]</td>
<td>$r[CreatedDate]</td>
<td>$r[LastUpdatedBy]</td>
<td>$r[LastUpdatedDate]</td>
<td>
<button id='edit' onclick=\"popup_window_show('#sample', { pos : 'tag-right-down', parent : this});\"'><image src='images/Edit.png'/>Edit</button> |
<button id='delete'><image src='images/delete.png'/>Hapus</button>
</td>
</tr>";
$no++;
}
?>
</table>
当用户点击“编辑”弹出窗口中的所有字段时,我的目的是使用LoginID作为我的sql中的参数填充相关数据。我使用ms sql 2008作为mya数据库服务器。 我的问题是如何使用Jquery为每一行从数组“$ r [LoginID]”获取单个数据。
答案 0 :(得分:0)
将LoginID
作为参数传递给onClick按钮,例如
<button id='edit' onclick=\"popup_window_show('#sample', '$r[LoginID]' ,{ pos : 'tag-right-down', parent : this});\"'>
并使用jQuery向页面发出ajax调用,该页面返回与LoginID相关的数据,并在编辑表单中填充所有可编辑的文件。