Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 未捕获类型错误:无法设置属性'_DT#U CellIndex';使用rowspan时的未定义值_Php_Jquery_Foreach_Html Table_Datatables - Fatal编程技术网

Php 未捕获类型错误:无法设置属性'_DT#U CellIndex';使用rowspan时的未定义值

Php 未捕获类型错误:无法设置属性'_DT#U CellIndex';使用rowspan时的未定义值,php,jquery,foreach,html-table,datatables,Php,Jquery,Foreach,Html Table,Datatables,我有一个表,其中包含使用foreach循环填充的数据库结果的记录。 但是,表的最后一列“Roll-Over”是具有rowspan属性的单个单元格值。 我正在为表使用dataTable插件 <table class="table table-striped table-hover" id="leave_balance_table"> <thead> <tr> <th>

我有一个表,其中包含使用foreach循环填充的数据库结果的记录。 但是,表的最后一列“Roll-Over”是具有rowspan属性的单个单元格值。 我正在为表使用dataTable插件

      <table class="table table-striped table-hover" id="leave_balance_table">
        <thead>
            <tr>
                <th>Leave Type</th>
                <th>Max Days</th>
                <th>Leave Taken</th>
                <th>Leave Balance</th>
                <th>Roll Over</th>
            </tr>
        </thead>
        <tbody>
        <?php
        $totalLeaveTaken = 0.00;
        $totalBalance = 0.00;
        $totalRows = count($GetEmployeeLeaveBalance);
        $lastColumnPrinted = false; //Add This
            foreach ($GetEmployeeLeaveBalance as $member):
                $totalLeaveTaken += $member['usedDays'];
                $totalBalance += $member['Remaining_Leave_Days'];
                $leaveBalance = floatval($member['Remaining_Leave_Days']);
            ?>
            <tr>
                <td><?php echo $member['title']; ?></td>
                <td><?php echo $member['maxDays']; ?></td>
                <td><?php echo $member['usedDays']; ?></td>
                <!-- <td><?php echo gettype($leaveBalance);?></td> -->
                <td
                <?= 
                ($leaveBalance < 0) ? 
                "style='background-color:red;font-weight:bold;color:white;'" : ""
                ?>
                >
                <?php echo $member['Remaining_Leave_Days']; ?>    
                </td>

                <!--Add The Line Below -->
                <?php if($lastColumnPrinted == false): $lastColumnPrinted = true;?>
                  <td rowspan="<?= $totalRows; ?>">Some computed value</td>
                <?php endif; ?>

            </tr>
        <?php endforeach; ?>
        <tr>
            <td></td>
            <td></td>
            <td style="background-color: #33CCFF; font-weight: bold;">Total: <?php echo number_format($totalLeaveTaken, 2); ?></td>
            <td style="background-color: #33CCFF; font-weight: bold;">Total: <?php echo 
            number_format($totalBalance, 2); ?></td>
            <td></td>
        </tr>
        </tbody>
    </table>
结果和预期的一样,但是我在控制台中遇到了上面提到的错误。
这是因为表中有空单元格吗?

您必须包括最后一个
,否则这将失败,如果没有错误,则有一个针对空解决方案的JavaScript解决方案,只需在最后一行添加一个可能重复的@William-H-M。我不想把s和s搭配起来。最后一列单元格将对使用rowspan的所有行公用。你能帮我吗?问题是数据表,但你可以这样做。你必须包括最后一个
,否则这将失败,如果没有错的话,有一个空解决方案的JavaScript解决方案,只有一秒可能重复的@William-H-M我在最后一行添加了一个。我不想把s和s搭配起来。最后一列单元格将对使用rowspan的所有行公用。你能帮我吗?问题是数据表,但你可以找人来做。
Leave Type | Max Days | Leave Taken | Leave Balance | Roll Over
Float      | 3        | 2           | 1             | 5
Personal   | 3        | 2           | 1             |   
Sick       | 3        | 2           | 1             | 
Mourning   | 3        | 2           | 1             |