模态代码: × Delete confirmati-6ren">
gpt4 book ai didi

javascript - modal中从MySQL获取用户信息

转载 作者:行者123 更新时间:2023-11-29 11:18:54 27 4
gpt4 key购买 nike

基本上我拥有的是用户列表,其中包含 1 个辅助电子邮件和其他辅助操作。其中一项操作是“删除”,即以下代码:

按钮:

<button type="button" class='btn btn-danger btn-xs' data-toggle="modal" data-target="#modal_DELETE" data-whatever="<?php echo $sub["adminEmail"]; ?>"> <span class="fa fa-times"> </span> </button><a> </a>

模态代码:

<div class="modal fade" id="modal_DELETE" tabindex="-1" role="dialog" aria-labelledby="modal_nameDELETE">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="modal_nameDELETE">Delete confirmation</h4>
</div>
<form method="post">
<div class="modal-body">
Are you sure you want to remove user:</label>
<input type="text" class="form-control" id="recipient-name" disabled>
<input type="hidden" class="form-control" id="idx" name="email_to_remove">
<br>
</div>
<div class="modal-footer">
<button type="submit" class="btn btn-default" data-dismiss="modal">No</button>
<button type="submit" class="btn btn-primary" name="delete">Yes</button>
</div>
</form>
</div>
</div>
</div>

JavaScript:

<script>
$(function(){
$('#modal_DELETE').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
var recipient = button.data('whatever');
var modal = $(this);
modal.find('.modal-body input').val(recipient);


});
});
</script>

但是现在我在编辑时遇到问题,因为我想做一些 PHP 代码。基本上它会说用户许可,但你可以编辑它。像这样:

<?php
$permissions = $conn->prepare("SELECT * FROM sub_permission WHERE id_bota=:id");
$permissions->bindParam(":id",$ID);
$permissions->execute();
$pInfo = $permissions->fetch(PDO::FETCH_ASSOC);
?>
<label><h4>Changing connection info</h4>
<select input style="width:200px; overflow:hide;" type="text" name="config_connectionInfo" class="form-control">
<?php if($pInfo["config_connectionInfo"] == 1){ ?>
<option value="1">Yes</option>
<option value="0">No</option>
<?php }else{ ?>
<option value="0">No</option>
<option value="1">Yes</option>

<?php } ?>
</select>
</label>

我有一个表单,但我只是不知道如何将电子邮件传递给 MySQL 选择查询。然后在模式中它将显示所有权限,如果分配了权限,它会说 是的 不或者如果它没有被分配 不 是的

最佳答案

您必须在代码中放置 ajax 请求才能与 php 交互。

$(function(){
$('#modal_DELETE').on('show.bs.modal', function (event) {
var button = $(event.relatedTarget);
var recipient = button.data('whatever');
var modal = $(this);
modal.find('.modal-body input').val(recipient);
$.ajax({
url: 'phpScript.php',
method: 'post',
data: {
//Your data
}
}).done(function(response){
//PHP end execution
});

});
});

http://api.jquery.com/jquery.ajax/

关于javascript - modal中从MySQL获取用户信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39294565/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com