以模态获取MySQL的用户信息

时间:2016-09-02 14:15:55

标签: javascript php html mysql

基本上我所拥有的是具有单边电子邮件和其他边操作的用户列表表。 其中一个操作是删除,即此代码:

按钮:

<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选择查询。然后在模态中它将显示所有权限,如果分配了权限,它会说     是     没有 或者如果没有分配     没有     是

1 个答案:

答案 0 :(得分:1)

您必须在代码中添加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/