我正在使用 php 创建一个表,这就是它创建表体的方式。
while (mysqli_stmt_fetch($stmt)) {
// Create Table Body
$html .= "<tr>\n";
$html .= " <td>$title</td>\n";
$html .= " <td>$date</td>";
$html .= " <td align='center'>\n";
$html .= " <a href='#'>\n";
$html .= " <span class='view' title='View This Comment'></span>\n";
$html .= " </a>\n";
$html .= " </td>\n";
$html .= " <td class='td_catchall' align='center'>\n";
$html .= " <a href='#'>\n";
$html .= " <span class='edit' title='Edit This Comment'></span>\n";
$html .= " </a>\n";
$html .= " </td>\n";
$html .= " <td align='center'>\n";
$html .= " <a href='#'>\n";
$html .= " <span class='delete' title='Delete This Comment'></span>\n";
$html .= " </a>\n";
$html .= " </td>\n";
$html .= "</tr>\n";
}
使用此表有 3 列可查看、编辑和删除每条评论。我想为每个动作触发一个 jquery 对话框。我试图让它与视图对话框一起工作。但它只为每个链接显示一条评论。我在while循环中添加了代码来查看对话框,如下所示 -
//Create View Blog Dialog Box
$viewBlog = "<div id='dialog-view'>\n";
$viewBlog .= " <h2>$title</h2>\n";
$viewBlog .= " <p>$date</p>\n";
$viewBlog .= " <p>";
$viewBlog .= " <img src='".UPLOAD_DIR.$userName."/".$image."' />";
$viewBlog .= " $comment</p>";
$viewBlog .= "</div>\n";
更新
我的 jQuery -
$( "#dialog-view" ).dialog({
autoOpen: false,
height: 450,
width: 650,
modal: true,
buttons: {
Cancel: function() {
$( this ).dialog( "close" );
}
},
position: {
my: "center top",
at: "center top",
of: "#content"
}
});
$( ".view" ).click(function() {
$( "#dialog-view" ).dialog( "open" );
});
任何人都可以帮助解决这个问题。谢谢你。