0

这是我一直在处理的分页脚本:

http://pastebin.com/4mpjdWKD

这是显示记录的查询页面 - 但它省略了第一条记录:

http://pastebin.com/kJZy9fv0

实际查询是这样的:

    <?php
   //Require the file that contains the required classes
   include("pmcPagination.php");

   //PhpMyCoder Paginator
   $paginator = new pmcPagination(20, "page");

   //Connect to the database
   mysql_connect("localhost","root","PASSWORD HIDDEN FOR SECURITY REASONS");
   //Select DB
   mysql_select_db("housemde");

   //Select only results for today and future   
        $result = mysql_query("SELECT * FROM housemd WHERE expiration > NOW() 
        order by airdate;");
        $recordCount = mysql_num_rows($result);


   //You can also add reuslts to paginate here
   mysql_data_seek($result,0) ;
           while ($row = mysql_fetch_array($result))
   {
    $paginator->add(new paginationData($row['programme'],
               $row['channel'],
               $row['airdate'],
               $row['expiration'],  
                           $row['episode'],  
                           $row['series'],  
                           $row['epno'],  
               $row['setreminder']));
   }
  ?>

并且日期都在未来,甚至要显示第一条记录,我必须在 PhpMyadmin 中复制它 - 那么我的脚本有什么问题?

是否与 mysql_fetch_array 有关,如果是,我需要在哪里修复脚本?

无论如何,这是来自数据库的数据,所有显示未来事件的记录:

http://pastebin.com/gwcv7qza

简而言之,基本问题是,有时我必须手动复制记录以使其显示在脚本中,并且我正在尝试找到解决方案 - 但我在寻找解决方案时遇到了麻烦。我自己试过了,没用。

我希望我已经解释得足够好。

任何有关解决此问题的帮助表示赞赏(只需在我的 pastebin 链接中发布解决方案,如果需要,您可以在其中提交对 pastebin 的更正/修改。)

谢谢!

4

1 回答 1

0

I think the problem is in your Paginatop class

this row $result = ($page - 1) * $resultsPerPage + 1; will return 1 for the first page and you will show the second element in $this->items[$result] array - $this->items[1], not the first $this->items[0].

Give it a try with $result = ($page - 1) * $resultsPerPage;

for page 1 $result will be 0 for page 2 $result will be 19 (if showing 20 records per page)

于 2010-10-18T12:48:08.820 回答