PHP + bootstrap - 在模态之间切换

时间:2017-03-04 12:27:11

标签: php twitter-bootstrap

我在尝试在两个模态窗口之间切换时遇到问题。请求您提供相同的指导

目标

在我的页面中,我有一个链接。当我点击该链接时,我的模态1打开。这个模型1有一个链接,当我点击打开2.

代码

示例页面 - 模态窗口1 - 以下内容是模态1的一部分

<div class="row">
    <div class="col-md-12"> 
        <?php 
         if($_SESSION['role'] == "Business")
            { ?>
             <div class="form-group" id="buscomments">
                <a href="busscomments.php?id=<?php echo $response['id']; ?>" data-target="#busscomments" data-toggle="modal">View Business Comments</a>
             </div>
    </div>
    <div class="col-md-12"> 
        <?php }else { ?>    
            <div class="form-group" id="othcomments">
                <a href="othcomments.php?id=<?php echo $response['id']; ?>" data-target="#othcomments" data-toggle="modal">View Other Comments</a>
            </div>
        <?php } ?>
    </div>

现在在同一个HTML文件中 - 我有两个其他模型

  <div class="modal fade text-center" id="busscomments">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
    </div>
  </div>
</div>


<div class="modal fade text-center" id="othcomments">
  <div class="modal-dialog" role="document">
    <div class="modal-content">
    </div>
  </div>
</div>

这些模态的模态内容可在busscomments.php和 othcomments.php分别

输出

我的模态1正确打开但是当我点击busscomments.php链接时,理想情况下应该打开模态2,不会发生。我可以看到淡入淡出效果,但没有显示模态

我所说的:

我提到了下面的链接并尝试修改我的代码但没有运气 Stackoverflow link 1

不确定我错过了什么。我知道传统上使用Jquery做同样的事情应该是理想的。但是在这方面的任何帮助都会有所帮助。

如果我需要更多信息,请告诉我。

由于

更新:

Othcomments.php

<div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
        <span aria-hidden="true">&times;</span>
        <span class="sr-only">Close</span>
    </button>
    <h4 class="modal-title">Other Comments</h4>
</div>
<div class="modal-body">
    <div class ="table-responsive">
                <table class="table table-striped">
                    <thead>
                        <tr>
                            <th class="col-md-1">Other Comments</th>
                        </tr>
                    </thead>
                    <?php 
                        while(mysqli_stmt_fetch($statement))
                            {
                                $response = array("oth"=>$othcomments);
                    ?>
                    <tbody>
                        <tr>
                            <td><?php echo $response['oth']; ?></td>
                        </tr>
                    </tbody>
                    <?php   } ?>
                </table>    
    </div>                                  
</div>

1 个答案:

答案 0 :(得分:0)

MY BAD ..我绝对搞砸了模态ID。我互换了Id,并没有数据库的结果。我解决了这个问题。谢谢