javascript - 液晶电视自动分页显示日程信息

标签 javascript php html mysql pagination

我想在液晶电视上显示一些日程安排信息。为此,我设法创建一个显示数据的 php 页面。我设置每页显示10条数据,为此有分页代码。

它运行良好,但我想自动运行该分页;这意味着几秒钟后页面会自动转到第二页,然后第三页等,并在到达最后一页后重新开始循环。我不知道如何实现这个。

以下是引用代码:

分页.php:-

<?php
$con = mysql_connect("localhost","root",""); 
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  mysql_select_db("test", $con); //Provide database name which has our data for pagination.

  $query = mysql_query("select CTime, Venue, Lecturer, Subject, Course from schedule where TDate = CURRENT_DATE"); 
  $total_rows = mysql_num_rows($query);

  $base_url = 'https://localhost/page/';    
  $per_page = 10;                           
  $num_links = 8;                           
  $total_rows = $total_rows; 
  $cur_page = 1;                           


    if(isset($_GET['page']))
    {
      $cur_page = $_GET['page'];
      $cur_page = ($cur_page < 1)? 1 : $cur_page;            
    }

    $offset = ($cur_page-1)*$per_page;             
    $pages = ceil($total_rows/$per_page);              

    $start = (($cur_page - $num_links) > 0) ? ($cur_page - ($num_links - 1)) : 1;
    $end   = (($cur_page + $num_links) < $pages) ? ($cur_page + $num_links) : $pages;

    $res = mysql_query("select CTime, Venue, Lecturer, Subject, Course from schedule where TDate = CURRENT_DATE LIMIT ".$per_page." OFFSET ".$offset);

 mysql_close($con);
  ?>

索引.php:-

<!DOCTYPE html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="eng">
    <head>
    <?php

    ?>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <title>Pagination</title>
        <link href="column-options.css" rel="stylesheet" type="text/css" />
        </head>
    <body>
        <div id="kotak">    
    <?php

    include("pagination.php"); 


        if(isset($res))
        {


            echo '<table class="stat">';           
            echo'<th>Class Duration</th><th>Venue</th><th>Lecturer</th><th>Subject</th><th>Course</th></tr>'; 
            while($result = mysql_fetch_assoc($res))
            {
              echo '<tr>';
              echo '<td>'.$result['CTime'].'</td>'.'<td>'.$result['Venue'].'</td>'.'<td>'.$result['Lecturer'].'</td>'.'<td>'.$result['Subject'].'</td>'.'<td>'.$result['Course'].'</td>' ;
              echo '</tr>';
            }
            echo '</table>';

        }

    ?>
    </div>

    <div id="pagination">
        <div id="pagiCount">
            <?php

                if(isset($pages))

                {  
                    if($pages > 1)        
                    {    if($cur_page > $num_links)    
                        {   $dir = "first";
                            echo '<span id="prev"> <a href="'.$_SERVER['PHP_SELF'].'?page='.(1).'">'.$dir.'</a> </span>';
                        }
                       if($cur_page > 1) 
                        {
                            $dir = "prev";
                            echo '<span id="prev"> <a href="'.$_SERVER['PHP_SELF'].'?page='.($cur_page-1).'">'.$dir.'</a> </span>';
                        }                 

                        for($x=$start ; $x<=$end ;$x++)
                        {

                            echo ($x == $cur_page) ? '<strong>'.$x.'</strong> ':'<a href="'.$_SERVER['PHP_SELF'].'?page='.$x.'">'.$x.'</a> ';
                        }
                        if($cur_page < $pages )
                        {   $dir = "next";
                            echo '<span id="next"> <a href="'.$_SERVER['PHP_SELF'].'?page='.($cur_page+1).'">'.$dir.'</a> </span>';
                        }
                        if($cur_page < ($pages-$num_links) )
                        {   $dir = "last";

                            echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$pages.'">'.$dir.'</a> '; 
                        }   
                    }
                }
            ?>
        </div>
    </div>  
</body>
</html>

最佳答案

我找到了解决方案:

header('Refresh: 10; URL='.$_SERVER['PHP_SELF'].'?page='.$nextpage);

关于javascript - 液晶电视自动分页显示日程信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26204488/

相关文章:

html - 如何消除具有相同背景颜色的三个 div 之间的奇怪间隙?

javascript - Onsubmit 在 div 上显示成功消息

javascript - 在 jQuery 悬停时移动 div 背景位置

javascript - Jquery Unobtrusive Validation 'Cannot read property ' 类型“未定义”

php - smarty 替换换行符

php - Wordpress - 根据元字段内容获取帖子

javascript - 动态更改 div ID 和 div 内其他元素的 ID

javascript - 从 JavaScript 构造函数返回公共(public)接口(interface)

php - 如何使用多个命令创建一个导航

html - 过滤灰色图像,黑色周围png ie8