php html 在一个电视仪表盘中显示大量动态 table 数据

php html show large dynamic table data in one tv dashboard

我有一台 TV Dashboard(无触摸)。我想从数据库 PHP/MySQL 中动态显示一些信息。 但这里有一个问题:当 table 行超过屏幕高度时,我想自动显示第二页,10 秒后我想自动返回到第一页。全部处于循环模式。有可能吗?

谢谢。

我有这样的代码:

<table class="table">
    <thead>
       <tr>
        <th id="th_left">Ticket ID</th>
        <th id="th_left">Device Model</th>
        <th id="th_left">Client Name</th>
       </tr>
    </thead>



                    <?php
                       for ($j=0; $j<count($to_display_list); $j++) {
                           $a = $to_display_list[$j]->status_id;
                    ?>
    <tbody>
      <tr>
        <td><strong><?php echo $to_display_list[$j]->ticket_id ?></strong></td>
        <td><strong><?php echo $to_display_list[$j]->device_model ?></strong></td>
        <td><strong><?php echo $to_display_list[$j]->client_name ?></strong></td>
      </tr>
    </tbody>
    <?php           
    }
    ?>
</table>

你能帮帮我吗?

<head> 中放置:

<?php
// connect to database here and do what you need to get the variable $to_display_list

if(count($to_display_list)>=30){
    $page = $_GET['p'];
    if($page == "1"){
        echo '<meta http-equiv="refresh" content="10; url=page.php?p=2">'; // replace page.php with your file name
    }else{
        echo '<meta http-equiv="refresh" content="10; url=page.php?p=1">'; // replace page.php with your file name
    }
}else{ // less than 30 items, only display one page
    echo '<meta http-equiv="refresh" content="10">';
}
?>

然后将上面的代码部分替换为:

<table class="table">
    <thead>
       <tr>
        <th id="th_left">Ticket ID</th>
        <th id="th_left">Device Model</th>
        <th id="th_left">Client Name</th>
       </tr>
    </thead>



 <?php 
   if(count($to_display_list)>=30){ 
       if($page == "1"){
           for ($j=0; $j<count($to_display_list)/2; $j++) {
           $a = $to_display_list[$j]->status_id;    
       }else{
           for ($j=count($to_display_list)/2; $j<count($to_display_list); $j++) {
              $a = $to_display_list[$j]->status_id;
           }
   }else{ // less than 30 items to display
       for ($j=0; $j<count($to_display_list); $j++) {
           $a = $to_display_list[$j]->status_id;
   }
 ?>
    <tbody>
      <tr>
        <td><strong><?php echo $to_display_list[$j]->ticket_id ?></strong></td>
        <td><strong><?php echo $to_display_list[$j]->device_model ?></strong></td>
        <td><strong><?php echo $to_display_list[$j]->client_name ?></strong></td>
      </tr>
    </tbody>
    <?php           
    }
    ?>
</table>

这使用 GET 方法和元刷新将页面 URL 更新为 ?p=1 或 ?p=2 并根据页面读取显示列表的不同部分。
它将在 "page 1" 上显示一半数据,在 "page 2" 上显示另一半数据。

    Andreas, I have another question:
    If there is less rows, mean "<30", why I need to display page.php?p=2  ???
    Below is my working code based on your answer (testing)
    Thank you.
<html>
<head>
    <?php
        $page = $_GET['p'];
        if($page == "1"){
            echo '<meta http-equiv="refresh" content="10; url=page.php?p=2">'; // replace page.php with your file name
        }else{
            echo '<meta http-equiv="refresh" content="10; url=page.php?p=1">'; // replace page.php with your file name
        }
    ?>
</head>
<body>
    <table border="1">
        <thead>
            <tr>
                <th>ID</th>
                <th>NUMBER</th>
                <th>MODEL</th>
                <th>NAME</th>
                <th>IN</th>
                <th>START</th>
                <th>PRICE</th>
                <th>WAITING</th>
                <th>DONE</th>
                <th>TIME</th>
            </tr>
        </thead>
        <tbody>
        <?php 
            if($page == "1"){
                for ($x=0; $x<30/2; $x++) {
        ?>
            <tr>
                <td><strong><?php echo $x ?></strong></td>
                <td><strong>4545465</strong></td>
                <td><strong>ANY MODEL</strong></td>
                <td><strong>EMMET BROWN</strong></td>                       
                <td></td>
                <td></td>
                <td></td>
                <td>X</td>
                <td></td>   
                <td>00:05:08</td>
            </tr>
        <?php } } else {
            for ($x=30/2; $x<30; $x++) {    
        ?>
            <tr>
                <td><strong><?php echo $x ?></strong></td>
                <td><strong>4545465</strong></td>
                <td><strong>ANY MODEL</strong></td>
                <td><strong>EMMET BROWN</strong></td>                       
                <td></td>
                <td></td>
                <td></td>
                <td>X</td>
                <td></td>   
                <td>00:05:08</td>
            </tr>
        <?php }} ?>
        </tbody>
    </table>
</body>
</html>