views:

18

answers:

1

This is my pagination script, which I've been working on:

http://pastebin.com/4mpjdWKD

This is the query page which displays the records - but it omits the first record:

http://pastebin.com/kJZy9fv0

The actual query is this:

    <?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']));
   }
  ?>

and the dates are all in the future, yet to even get the first record to show, I have to duplicate it in PhpMyadmin - so what is wrong with my script?

Is it something to do with mysql_fetch_array, and if so, where do I need to fix the script?

In any case, here's the data from the database, all showing records for future events:

http://pastebin.com/gwcv7qza

In short, the basic problem is, I have to manually duplicate a record to get it to show in the script sometimes, and I'm trying to find a fix - but I'm having trouble looking for a solution. I've tried myself, and it didn't work.

I hope I've explained this well enough.

Any help on fixing this is appreciated (just post the solutions in my pastebin links where it allows you to submit a correction/amendment to the pastebin, if you want.)

Thanks!

A: 

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)

Yasen Zhelev