第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使用行跨度對(duì)表數(shù)據(jù)進(jìn)行分組

使用行跨度對(duì)表數(shù)據(jù)進(jìn)行分組

PHP
阿晨1998 2022-01-24 10:41:49
我的桌子目前的外觀我想要一個(gè)使用行跨度的側(cè)列,該列具有支付期間并將該支付期間的日期分組在一起。我希望主管能夠創(chuàng)建一個(gè)新的支付期,該支付期在數(shù)據(jù)庫(kù)中生成一個(gè)整數(shù),然后行跨度將對(duì)該支付期內(nèi)提交的任何數(shù)據(jù)進(jìn)行分組。我當(dāng)前的表代碼:    <div class="table-responsive">        <table id="editable_table" class="table table-bordered table-striped" data-editable="true" data-buttons-toolbar=".toolbar" data-search="true"data-show-refresh="true" >            <thead>                <tr>                    <th>Index</th>                    <th>Employee ID</th>                    <th>Username</th>                    <th>Date</th>                    <th>Time In</th>                    <th>Time Out</th>                    <th>Total Hours</th>                    <th>Submit Status</th>                    <th>Approved Status</th>                    <th>Time Change</th>                    <th>Edit</th>                </tr>            </thead>            <tbody>                <?php                    while($row = $res->fetch()){                        echo '                        <tr>                        <td>'.$row["id"].'</td>                        <td>'.$row["user_id"].'</td>                                            <td>'.$row["name"].'</td>                        <td>'.$row["submit_day"].'</td>                        <td>'.$row["time_in"].'</td>                        <td>'.$row["time_out"].'</td>                        <td>'.$row["total_hours"].'</td>                                                                        <td>'.$row["submit_status"].'</td>                        <td  style="color:green;">'.$row["approve_status"].'</td>                       <td>'.$row["change_request"].'</td>                       <td><center><a id="editbtn" href="action.php?id='.$row["id"].'"><span class="glyphicon glyphicon-edit"></span></a></td>                      </tr>';                }             ?>        </tbody>        </table>    </div>我不確定如何使用 rowspan 來(lái)整理數(shù)據(jù),使其看起來(lái)像這樣: 示例表
查看完整描述

1 回答

?
慕尼黑的夜晚無(wú)繁華

TA貢獻(xiàn)1864條經(jīng)驗(yàn) 獲得超6個(gè)贊

我正在更新我的答案,因?yàn)樗蛭粗蚨唤导?jí),沒(méi)有人會(huì)解釋。


所以這是我的回答,基于我所做的和基于邏輯的。


簡(jiǎn)而言之,不要嘗試在 PHP 中做你想做的事情,因?yàn)樗鼤?huì)在你的循環(huán)代碼中創(chuàng)建太多額外的工作和復(fù)雜性,否則你需要進(jìn)行預(yù)先計(jì)算以知道要為數(shù)量設(shè)置的行跨度該期間的項(xiàng)目在輸出該期間的項(xiàng)目之前。


在我繼續(xù)之前,不妨問(wèn)自己一個(gè)問(wèn)題:“為什么我只需要在周期發(fā)生變化時(shí)打印一次,這對(duì)最終用戶有什么幫助?如果有的話?”


由于您仍在使用列,因此嘗試按句點(diǎn)對(duì)它們進(jìn)行分組并沒(méi)有節(jié)省任何空間,因此您可以在頁(yè)面的下方一直重復(fù)該列中的句點(diǎn),因?yàn)槿绻腥讼蛳聺L動(dòng)并且句點(diǎn)不在左側(cè)他們可能需要向上滾動(dòng)才能記住他們所處的時(shí)期。


如果您想避免 PHP 預(yù)先計(jì)算并且仍然做您想做的事情,您可以僅在您知道它已更改時(shí)打印句點(diǎn),然后使用 CSS 像這樣格式化表格。


例如:


$lastPeriod="";

while($row = $mysqli->fetchassoc($res)){

    echo "<tr>";

    if($lastPeriod == $row["period"]){

        echo "<td>&nbsp;</td>";

    } else {

        echo "<td class='period'>$row[period]</td>";

    }

    // echo the rest of the cells in the row

    echo "</tr>";

    $lastPeriod = $row["period"];

}

table{

border-collapse:collapse;

}

table tr th,

table tr td{

padding:5px;

border-color:#dddddd; /* Only have to set colour once this way*/

border-style:solid;

border-width:0px 0px 1px 0px;

}

table tr th{

background-color:#eeeeee;

}

table tr td:first-child{

border-width:0px;

}

table tr td.period{

  border-width:0px 0px 1px 0px !important;

  font-weight:bold;

 }

<table>

<tr>

<th>Period</th>

<th>Name</th>

<th>Day</th>

<th>Options</th>

</tr>

<tr>

<td class='period'>September</td>

<td>John</td>

<td>01</td>

<td>-</td>

</tr>

<tr>

<td></td>

<td>Mary</td>

<td>05</td>

<td>-</td>

</tr>

<tr>

<td></td>

<td>Joe</td>

<td>06</td>

<td>-</td>

</tr>

<tr>

<td class='period'>October</td>

<td>John</td>

<td>22</td>

<td>-</td>

</tr>

</table>


查看完整回答
反對(duì) 回復(fù) 2022-01-24
  • 1 回答
  • 0 關(guān)注
  • 154 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)