doufei1852 2017-03-30 10:22
浏览 48

如何让我的模态信息显示,同时尝试使其动态化?

Trying to open a modal which should grab information from my database and present it onto the modal, after clicking on a specific image. The modal pops up, but it shows on the html inputs and none of the php inputs. How can i fix this? rental_id is the primary in the database table.

<?php
 require_once '../core/init.php';
$id = $_POST['rental_id'];
$id = (int)$id;
$sql = "SELECT * FROM rental WHERE rental_id = '$id'";
$result = $db->query($sql);
$rental = mysqli_fetch_assoc($result);

 ?>

 <!-- the div that represents the modal for the form -->
 <?php ob_start();?>
            <div class="modal fade" id="quote" tabindex="-1" role="dialog" aria-labelledby="quote" aria-hidden="true">
                <div class="modal-dialog modal-lg">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button class="close" type="button" data-dismiss='modal' aria-label="Close">
                                <span aria-hidden="true">&times;</span>
                            </button>
                            <h4 class="modal-title text-center">Quote</h4>
                        </div>
                        <div class="modal-body">
                            <div class="container-fluid">
                                <div class="row">
                                <div class="col-sm-6">
                                <div class="center-block">
                                    <img src="<?= $rental['img']; ?>" alt="<?= $rental['make']; ?>" class="w3-image img-responsive"/>
                                </div>...

and...

<script>
    function detailsmodal(rental_id){
        var data = {"rental_id" : rental_id};
        jQuery.ajax({
            url : <?php echo BASEURL;?> + 'includes/detailsmodal.php',
            method : "post",
            data : data,
            success: function(data){
                jQuery('body').append(data);
                jQuery('#quote').modal('show');
            },
            error: function(){
                alert("Something went wrong!");
            }
        });
    }
</script>
  • 写回答

1条回答 默认 最新

  • dongshai2022 2017-03-30 11:12
    关注

    Have you checked $id = (int)$id; ? is it set, ok with a value ? Any return error message ? (SO question )

    <?php     
    print_r($rental); /* seems ok when tested with ie: $id=3 */
    
    $sql = " SELECT img, make FROM rental WHERE rental_id=? ";
    $stmt = $mysqli->prepare($sql);
    $stmt->bind_param("s", $id);
    
    $results = $stmt->execute();
    $stmt->bind_result($img, $make);
    $stmt->store_result();
    
    while($stmt->fetch()){
    echo"[ $img / $make ]";
    }
    ?>
    

    does it make a difference ?

    评论

报告相同问题?

悬赏问题

  • ¥15 使用yolov5-7.0目标检测报错
  • ¥15 对于这个问题的解释说明
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥20 java在应用程序里获取不到扬声器设备