【问题标题】:Running jquery funtion over php mysql while loop在php mysql while循环上运行jquery函数
【发布时间】:2016-06-21 21:03:18
【问题描述】:

主要目的是在单击主行时显示该行,一个事件ID将有多个记录。如何为这种类型的输出应用 jquery 函数。帮助赞赏。

我尝试使用 jexpand 函数,但它不起作用。

主要目的是获得输出,例如,当单击一个特定行时,应展开具有相同 ID 的剩余行集,反之亦然。

表格结果是从mysql数据库中获取的。

<html>
    <head>
    <meta charset="UTF-8">
    <style type="text/css">
            body { font-family:Arial, Helvetica, Sans-Serif; font-size:0.8em;}
            #report { border-collapse:collapse;}
            #report h4 { margin:0px; padding:0px;}
            #report img { float:right;}
            #report ul { margin:10px 0 10px 40px; padding:0px;}
            #report th { background:#7CB8E2 url(header_bkg.png) repeat-x scroll center left; color:#fff; padding:7px 15px; text-align:left;}
            #childALL { background:#C7DDEE none repeat-x scroll center left; color:#000; padding:7px 15px; }
            #report tr.td { background:#fff url(row_bkg.png) repeat-x scroll center left; cursor:pointer; }
            #report div.arrow { background:transparent url(arrows.png) no-repeat scroll 0px -16px; width:16px; height:16px; display:block;}
            #report div.up { background-position:0px 0px;}
        </style>
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
        <script type="text/javascript">  
            $(document).ready(function(){
                $("#report tr:siblings").show();
                $("#report tr:siblings").hide();
                $("#report div.arrow").click(function(){
                    $(this).next("#childALL").toggle();
                    $(this).find(".arrow").toggleClass("up");
                });
                //$("#report").jExpand();
            });
        </script>
    </head>
<body>
    <center>
        <img src="abc.jpg" width="400px" height="100px" />
    </center>

    <?php
        $con=  mysqli_connect("172.28.212.145", "root", "root", "xxx");

        if(!$con)
        {
            die('not connected');
        }

        $con=  mysqli_query($con, "Select Incident_id,name,qualification from masterdata;");
       ?>
    <div>
        <center>
            <table id="report">
                <tr>
                    <th>Incident Id</th>
                    <th>name</th>
                    <th>Qualification</th>
                    <th></th>
                </tr>
                <?php
                $incident = null;
                while($row = mysqli_fetch_array($con))
                {
                    if( $row['Incident_id'] != $incident )
                    {   
                        $incident = $row['Incident_id'];
                ?>
                <tr>
                    <td>
                        <?php echo $row['Incident_id']; ?>
                    </td>
                    <td>
                        <?php echo $row['name']; ?>
                    </td>
                    <td>
                        <?php echo $row['JournalUdpdateChanges']; ?>
                    </td>
                    <td><div class="arrow"></div></td>
                </tr>

                <?php } else { ?>

                <tr id="childALL">
                    <td >
                        <?php echo $row['Incident_id']; ?>
                    </td>
                    <td >
                        <?php echo $row['name']; ?>
                    </td>
                    <td >
                        <?php echo $row['qualification']; ?>
                    </td>
                    <td >
                        <?php echo $row['Priority_im']; ?>
                    </td>
                </tr> 
                <?php
                    }
                }
                ?>
            </table>
        </center>
    </div>
</body>
</html>

【问题讨论】:

    标签: php jquery mysql css


    【解决方案1】:

    Bootstrap 可以轻松解决这个问题。

    Bootstrap Accordion

    【讨论】:

    • 这个可以应用于表格行列吗?
    猜你喜欢
    • 2015-08-06
    • 1970-01-01
    • 2012-11-11
    • 1970-01-01
    • 1970-01-01
    • 2018-12-14
    • 2011-11-30
    • 2021-05-17
    • 1970-01-01
    相关资源
    最近更新 更多