【发布时间】:2015-12-05 23:19:17
【问题描述】:
我正在显示一个包含两个选项(删除或更新)的值表。当我选择删除时,我想显示要删除的行。最后一点使用 Bootstrap 模态。
这是我的删除模式
<div class="modal bounceIn animated" id="Delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title" id="myModalLabel">Delete a Campaign</h4>
</div>
<div class="modal-body edit-content">
<p>Please find the campaign ID to be deleted below</p>
<input type="text" name="bookId" id="bookId" value="" />
<table class='table table-bordered'>
<tr>
<th>#</th>
<th>Description</th>
<th>Creation Date</th>
<th>Credit</th>
<th>ROI</th>
<th>Active</th>
</tr>
<?php
$id = $row['data-campaignid'];// This is where I am having the problem
$stmt = $user_home->runQuery("SELECT * FROM campaigns WHERE id_campaigns=:id");
$stmt->execute(array(":id"=>$id));
while($row=$stmt->fetch(PDO::FETCH_BOTH))
{
?>
<tr>
<th>
<?php print($row['id_campaigns']); ?>
</th>
<th>
<?php print($row['descripcion']); ?>
</th>
<th>
<?php print($row['fec_creacion']); ?>
</th>
<th>
<?php print($row['saldo']); ?>
</th>
<th>
<?php print($row['ROI']); ?>
</th>
<th>
<?php print($row['active']); ?>
</th>
</tr>
<?php
}
?>
</table>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
<!-- modal-content -->
</div>
<!-- modal-dialog -->
</div>
<!-- end -->
如您所见,我正在使用以下 JQuery 脚本将值“bookid”传递给模式
$(document).on("click", ".open-DeleteDialog", function () {
var myCampaignId = $(this).data('campaignid');
$(".modal-body #bookId").val( myCampaignId );
});
我遇到的困难是如何使用输入的值 (bookID) 将其传递给 PHP PDO 查询并执行它,同时能够在表上显示该数据。
【问题讨论】:
标签: php jquery twitter-bootstrap pdo bootstrap-modal