php html在一个tv仪表板中显示大型动态表数据
我有一个电视仪表板(不带触摸屏)。我想动态显示PHP/MySQL数据库中的一些信息。 但这里有一个问题:当表格行超过屏幕高度时,我想自动显示第二页,10秒后,我想自动返回第一页。全在环模式。有可能吗 多谢各位 我有这样的代码:php html在一个tv仪表板中显示大型动态表数据,php,html,mysql,dashboard,display,Php,Html,Mysql,Dashboard,Display,我有一个电视仪表板(不带触摸屏)。我想动态显示PHP/MySQL数据库中的一些信息。 但这里有一个问题:当表格行超过屏幕高度时,我想自动显示第二页,10秒后,我想自动返回第一页。全在环模式。有可能吗 多谢各位 我有这样的代码: <table class="table"> <thead> <tr> <th id="th_left">Ticket ID</th> <th id="t
<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>
票号
设备模型
客户名称
您能帮我吗?在
中放置以下位置:
<?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,并根据页面读取显示列表的不同部分。它将在“第1页”上显示一半的数据,在“第2页”上显示另一半的数据 安德烈亚斯,我还有一个问题:
如果行数较少,则表示“一个简单的解决方案是创建两个页面,然后进行元刷新,并在10秒后直接进入第二个页面,然后返回另一个页面。
确定吗?那么这是否意味着它不起作用?我不明白这个问题这个数据多久更新一次?它是否会经常更新,以至于在这10秒钟内,一切都可能不同?如果第1页上的最后一项也在10秒后显示在第2页上,因为数据已经更新,这会不会是一个问题?我会试试。非常感谢。保持联系。@Cristian AngeloLungu我注意到的一件事是,它可能会先显示“第2页”,然后开始循环。如果这是一个问题,我可以更改它,这样它将启动第1页上的循环非常感谢Andreas。您的解决方案正在运行。@Cristian尝试新的更新代码来修复<30项,如您在下面提到的。好的,那么神奇的数字是30?如果超过30行,您只需要显示一页,如果少于30行,则需要两页?在这种情况下,您将需要首先连接到数据库并计算条目数,然后如果>30,则按上述操作,否则只刷新页面。我认为这是可行的。我将用这个编辑我的答案,这样你们就可以明白我的意思了。@Andreas,它起作用了。是的,“30”是一个神奇的数字,因为屏幕上有“30”行。当第30行需要拆分为2或3页时。你的脚本还可以。非常感谢您的时间。如果您需要三页,您只需添加几行就可以得到三页。没问题:-)
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>