Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6539845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:54:28+00:00 2026-05-25T10:54:28+00:00

I’ve got the problem with using the function mysql_data_seek() in my pagination. When clicking

  • 0

I’ve got the problem with using the function mysql_data_seek() in my pagination. When clicking on links, it produces no problem, but when clicking on the last page of the pagination link, it produces an error like this:

Warning: mysql_data_seek() [function.mysql-data-seek]: Offset 14 is invalid for MySQL result index 6 (or the query data is unbuffered)

My code is below:

      $rpp = 3; 
      $adjacents = 4;
      $page = (!empty($_GET["page"]) ? intval($_GET["page"]) : 1);
    if($page<=0) $page = 1;
        $reload = $_SERVER['PHP_SELF'];
        $sql = "SELECT * FROM ".TABLE_IMAGE." ORDER BY id ASC";
        $qry = mysql_query($sql, $con);
        $tcount = mysql_num_rows($qry);
        $tpages = ($tcount) ? ceil($tcount/$rpp) : 1; 
                $i = 1;
        $count = 0;
        $j = ($page-1)*$rpp;
        while(($result = mysql_fetch_array($qry)) && (($count<$rpp) && ($j<=$tcount))){                                                            mysql_data_seek($qry,$j);
                $id = $result['id'];
        $img = $result['path'];
        $title = $result['title'];
        $detail = $result['detail'];
        $priority = $result['priority'];
        $active = $result['isActive'];                      
?><div id="block-image-slider"  class="<?php echo(($i%2==0)?'even':'odd')?>">
     <h2><?php echo $title ?></h2><span class="operation">[<a href="?action=edit&section=slider&id=<?php echo $id ?>">កែប្រែ</a>|<a href="?action=delete&section=slider&id='<?php echo $id ?>'">លុប</a>]</span>
            <div class="block-slider-image-body">
                <div class="left">
                     <ul>
                         <li>លេខរៀងទី<span class="space"><?php echo $id ?></span></li>
                         <li>កំនត់អទិភាពទី<span class="space"><?php echo $priority ?></span></li>
                         <li>ត្រូវបានបង្ហាញអោយឃើញ<span class="space"><?php echo (($active==1)?'បង្ហាញ':'មិនបង្ហាញ')?></span></li>
                         <li>អត្ថបទពេញ<div class="detail"><?php echo $detail ?></div></li>
                     </ul>
                </div>
             <div class="right">
          <img src="<?php echo '../../image/Slider/'.$img ?>" alt="<?php echo $title ?>" width="170" height="100" />
  </div>
 <div style="clear:both;"></div>
 </div>
</div>
 <?php
    $j++;
    $count++;
    $i++;
}
  include("../include/paginate.php");
  echo paginate_three($reload, $page, $tpages, $adjacents);

and this is the paginate.php code

<?php 
     function paginate_three($reload, $page, $tpages, $adjacents) {
    $prevlabel = "&lsaquo; Prev";
    $nextlabel = "Next &rsaquo;";

    $out = "<div class=\"pagin\">\n";

    // previous
    if($page==1) {
        $out.= "<span>" . $prevlabel . "</span>\n";
    }
    elseif($page==2) {
        $out.= "<a href=\"" . $reload . "\">" . $prevlabel . "</a>\n";
    }
    else {
        $out.= "<a href=\"" . $reload . "?action=slider&page=" . ($page-1) . "\">" . $prevlabel . "</a>\n";
    }

    // first
    if($page>($adjacents+1)) {
        $out.= "<a href=\"" . $reload . "\">1</a>\n";
    }

    // interval
    if($page>($adjacents+2)) {
        $out.= "...\n";
    }

    // pages
    $pmin = ($page>$adjacents) ? ($page-$adjacents) : 1;
    $pmax = ($page<($tpages-$adjacents)) ? ($page+$adjacents) : $tpages;
    for($i=$pmin; $i<=$pmax; $i++) {
        if($i==$page) {
            $out.= "<span class=\"current\">" . $i . "</span>\n";
        }
        elseif($i==1) {
            $out.= "<a href=\"" . $reload . "?action=slider\">" . $i . "</a>\n";
        }
        else {
            $out.= "<a href=\"" . $reload . "?action=slider&page=" . $i . "\">" . $i . "</a>\n";
        }
    }

    // interval
    if($page<($tpages-$adjacents-1)) {
        $out.= "...\n";
    }

    // last
    if($page<($tpages-$adjacents)) {
        $out.= "<a href=\"" . $reload . "?action=slider&page=" . $tpages . "\">" . $tpages . "</a>\n";
    }

    // next
    if($page<$tpages) {
        $out.= "<a href=\"" . $reload . "?action=slider&page=" . ($page+1) . "\">" . $nextlabel . "</a>\n";
    }
    else {
        $out.= "<span>" . $nextlabel . "</span>\n";
    }

    $out.= "</div>";

    return $out;
}

?>

PS: when clicking on the last link of the pagination page button, it displays the error message like the above. Moreover, I have no idea why the first record from my database always show in each page. Any help would be appreciated. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T10:54:29+00:00Added an answer on May 25, 2026 at 10:54 am

    There is no problem. You’re requesting row 14 when there are only 6.

    Also, I think it’s more efficient to use LIMIT [from], [amount] for pagination.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm making a simple page using Google Maps API 3. My first. One marker
I want to construct a data frame in an Rcpp function, but when I
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I've got a string that has curly quotes in it. I'd like to replace
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.