我有一个通过PHP显示的mysql查询。每个返回的记录都分配有一个复选框。表中的一列(ReleaseNumber)具有将不同记录分组的数字。如何按发布号创建可折叠的复选框组。我已附上一张当前状态和我要做什么的图像(俯视截图)。用户可以折叠或展开行组。如果选择了行组,则还将选择所有子行。

可以这样做吗?
当前:

期望的:


我的代码是:

<?php
    mysql_connect("localhost", "username", "password")or die("cannot connect");
    mysql_select_db("database")or die("cannot select DB");
    $sql="SELECT`despgoodsid` ,`crtd dept` ,`customer` ,`loc cust rel` ,`case no` ,`gross mass` ,`case width` ,`case length` FROM despgoods_alldetails WHERE transporttypename ='localjhb' AND locstatus ='unplanned' AND customer <>'customer' AND `loc cust rel` > 0 ";
    $result=mysql_query($sql);
    $count=mysql_num_rows($result);
    putenv("TZ=Africa/Johannesburg");

?>
<table border=0>
    <tr>
        <td>
            <form name="form1" method="post">
                <table border=0 id="hor-minimalist-a">
                    <tr>
                        <th>&nbsp;</th>
                        <th width=150><center>Release Number</th>
                        <th width=150>Dispatch Area</th>
                        <th width=150>Customer</th>
                        <th width=130><center>Case Number</th>
                        <th width=80><center>Weight</th>
                        <th width=80><center>Width</th>
                        <th width=80><center>Length</th>
                    </tr>
<?php
    while($rows=mysql_fetch_array($result)){
?>
                    <tr>
                        <td><input type="checkbox" name=check[]  value="<?php echo $rows['despgoodsid']; ?>"></td>
                        <td><center><?php echo $rows['loc cust rel']; ?></td>
                        <td><?php echo $rows['crtd dept']; ?></td>
                        <td><?php echo $rows['customer']; ?></td>
                        <td><center><?php echo $rows['case no']; ?></td>
                        <td><center><?php echo $rows['gross mass']; ?></td>
                        <td><center><?php echo $rows['case width']; ?></td>
                        <td><center><?php echo $rows['case length']; ?></td>

                    </tr>

<?php
    }
?>
                    </table>
                    <table>
                    <tr>
                        <td colspan=3><input name="Next" type="submit" id="Next" value="Next"></td>
                    </tr></table>


我需要一些Java来完成此工作吗?任何建议一如既往地受到赞赏?

谢谢并恭祝安康,
瑞安·史密斯

最佳答案

有几种方法可以实现此目的。您不需要Java。您需要Javascript。

以下jQuery函数应该可以帮助您:


http://api.jquery.com/hide/
http://api.jquery.com/show/

08-18 15:33