How To offset an HTML table with PHP to Subtract cell value of 1st row from 2nd row cell value of different columns

后端 未结 1 1387
悲哀的现实
悲哀的现实 2021-01-28 21:49

OK, so I\'m trying to solve this problem from last week and haven\'t found a solution yet I ask the Question so many times but not able to get the Code working so I\'m putting a

相关标签:
1条回答
  • 2021-01-28 22:24

    Try something along the lines of this. Only a guideline, the real implementation is up to you. Also I'd recommend you use {} rather than endwhile.

       <?php 
        $last_row = $mysqli_fetch_array($search_result));
        while($row = mysqli_fetch_array($search_result)){
        //this is pseudocode, you will need to convert to date objects
        $timediff = $last_row['StateStarttime'] - $row['StateEndtime'];
        ?>
            <tr>
                <td align="Center"><?php echo $row['id'];?></td>
                <td align="Center"><?php echo $row['EmpID'];?></td>
                <td align="Center"><?php echo $row['Date'];?></td>
                <td align="Center"><?php echo $row['Username'];?></td>
                <td align="Center"><?php echo $row['Computername'];?></td>
                <td align="Center"><?php echo $row['State'];?></td>
                <td align="Center"><?php echo $row['MinutesatState'];?></td>
                <td align="Center"><?php echo $row['StateStarttime'];?></td>
                <td align="Center"><?php echo $row['StateEndtime'];?></td>
                <td align="Center"><?php echo $row['Timestamp'];?></td>
                // echo $timediff
            </tr>
            <?php
            $last_row = $row;
        }?>
    
    0 讨论(0)
提交回复
热议问题