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

  • Home
  • SEARCH
  • 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 6549523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:06:11+00:00 2026-05-25T12:06:11+00:00

I am having problems with paging some results drawn from a Mysql database. This

  • 0

I am having problems with paging some results drawn from a Mysql database.

This is the code relating to the pagination:

    $max_results = 20; //Max listed query results

if(!isset($_GET['pg'])){ $pg = 1; } else { $pg = $_GET['pg']; }
$from = (($pg * $max_results) - $max_results);

/// START of MySQL results – Page numbering
$space_separated = implode(" ", $keywords_array);
/// Count total
$totals = mysql_result(mysql_query("SELECT COUNT(id)
            FROM products
            WHERE MATCH (`desc`)
            AGAINST ('".$space_separated."' IN BOOLEAN MODE)
            ORDER BY `desc`
            LIMIT $from, $max_results"),0);
$total_pgs = ceil($totals / $max_results);
$tempVar = 0; //Used in the generation of order form

///Now we search for our search term, in the field the user specified 

// Page limiter & result builder

$dataQuery = "SELECT id, `desc`, price1, pack, measure, quantity
              FROM products
              WHERE MATCH (`desc`)
              AGAINST ('".$space_separated."' IN BOOLEAN MODE)
              ORDER BY `desc`
              LIMIT $from, $max_results";
$result1 = mysql_query($dataQuery);
$num_sql = mysql_num_rows ($result1);
$data = mysql_query($dataQuery) or die(mysql_error());

$pageContent .= '
<div>
<p>Results: '.$totals.'</p>
<p>Viewing page '.$pg.' of '.$total_pgs.'</p>
</div>
<!-- end .aliLeft --></div>
';

$pageContent .= '
<p>'.$paginator.'</p>
';

/// Display results
if ($num_sql > 0 ) {$i=0;
while ($i < $num_sql) {
$holsite = mysql_result($result1,$i,"desc");
$pageContent .= ''.$holsite.'';
++$i;}}

$pageContent .= '
<p>'.$paginator.'</p>
';

I am adapting it from this tutorial : http://www.webdesign-4-beginners.co.uk/web-design-blog/2009/12/mysql-results-page-numbering/

I am getting the following mysql error:

Warning: mysql_result() [function.mysql-result]: Unable to jump to row 0 on MySQL result index 13 in /path-to/orders-layout.php on line 302

Also, when viewing page 2 of two, the result count is blank, and the pagination does not show the page numbers, only “previous page”. On page 1 of 2, everything looks as it should?
Does anyone have any idea what I have done wrong with this?

  • 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-25T12:06:12+00:00Added an answer on May 25, 2026 at 12:06 pm

    You must not limit your totals query. Remove limit from it.

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

Sidebar

Related Questions

I am having problems with paging some results drawn from a Mysql database. This
am having problems with some Regex code can anyone help. I have the following
Having problems getting the different arrays content from geocoder results. item.formatted_address works but not
Im having problems retrieving a field from my ms-access database. The table name is
Having problems returning a list of Japanese terms from an MSSql database as JSON.
I'm trying to do some basic paging in MSSQL. The problem I'm having is
im having problems with the following code: for (var i:Number=0; i<numFaces;i++){ var faceLoader:Loader =
I'm having some problems with the Sql query generated by LINQ, Since my environment
Having problems with this setup what im trying to do is like so. Steps
I'm having some paging issues when I wan't to display the next page with

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.