【问题标题】:Bootstrap Open Image in Modal having dynamic image srcBootstrap Open Image in Modal 具有动态图像 src
【发布时间】:2017-07-07 14:58:58
【问题描述】:

我的问题是关于这个答案。 Bootstrap open image in modal

如何显示 src 来自 MySQL 数据库的图像?

【问题讨论】:

    标签: php jquery twitter-bootstrap


    【解决方案1】:

    只需echo数据库中的img源即可。

    <?php 
      if(isset($_POST['profile_id'])){
         var uid=$_POST['profile_id'];
         $result->query("SELECT profile FROM user WHERE uid=$uid");
         $row=$result->fetch_array();
         die(json_encode($row));
      }
    ?>
    

    HTML:

    <a href="#" class="pop">
      <img src="" style="width: 400px; height: 264px;">
    </a>
    

    Jquery 部分:

    $.post("ajax.php",{profile_id:1},function(response){
       if(response){
         var profileImg=JSON.parse(response);
             profileImg=profileImg[0].profile;
             $('.pop img').attr('src','http://example.com/image/'+profileImg);
             $('.pop').modal('show');
       }
    });
    

    【讨论】:

    • Sarath 我知道 PHP 部分。我想知道如何使用 jquery 和 bootstrap 以模态显示图像。
    猜你喜欢
    • 1970-01-01
    • 2020-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-24
    • 2018-05-17
    • 1970-01-01
    • 2014-04-14
    相关资源
    最近更新 更多