问:while循环按钮中的PHP多模态

时间:2015-12-23 02:36:50

标签: javascript php jquery twitter-bootstrap

大家好,有人可以帮助我,我在while循环中执行了多个按钮。我想在每个按钮中查看单独的模态。

这是我的按钮:

<a href="#myModalRemarks" class="remarksBtn" data-toggle="modal"><i class="fa fa-info-circle fa-lg"></i></a>

我的按钮在while循环中,因为我想获取一个备注的数据,我想在我的模态中查看那些多个获取数据。

<?php
    include('connection.php');

    $sql1 = "SELECT remarks FROM tbl_encode_transmittal WHERE receiver_id = '".$_SESSION['userid']."'";

    $rs1 = mysql_query($sql) or die(mysql_error());

    while($row1 = mysql_fetch_array($rs1)){?>
        <!-- Modal -->
        <div class="modal fade" id="myModalRemarks" role="dialog">
            <div class="modal-dialog">
                <!-- Modal content -->
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal">&times;</button>
                        <h4 class="modal-title">Remarks</h4>
                    </div>
                    <div class="modal-body">
                        <?php echo $row1['remarks']; ?>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                    </div>
                </div>
           <?php } ?>
           </div>
        </div>

在我的代码的模态ID中,我想添加像<div class="modal fade" id="myModalRemarks1" role="dialog">这样的数字,每当我获取多个数据时,模态也有一个增量编号,这样它就会设置不同的id。

1 个答案:

答案 0 :(得分:1)

我建议您查看此question并按照答案采取更好的方法,至于您原来采用的方法

模态按钮(位于循环内)将行标识module.exports = { //The base directory (absolute path) for resolving the entry option context: __dirname, entry: { movies: '../movies_list/interfaces/index', series: '../series_list/interfaces/index', }, output: { // I need help here. path: path.join('<', "static"), //path: path.resolve('../[entry]/static/react_bundles/'), filename: "[name].js", }, } 添加到模态按钮receiver_id

href="#myModalRemarks<?php echo $row1['receiver_id'];?>"

模态HTML(也在循环内)将行标识<a href="#myModalRemarks<?php echo $row1['receiver_id'];?>" class="remarksBtn" data-toggle="modal"><i class="fa fa-info-circle fa-lg"></i></a> 添加到模态选择器标识receiver_id

id="myModalRemarks<?php echo $row1['receiver_id'];?>"

并且模态也将具有唯一的ID