Jump to content

remote paging of mysql query results fails


amwassil

Recommended Posts

I have a script that "includes" a script that queries a mysql database on a remote server. When accessed directly on the server  the mysql query results page nicely, with 20 results per page, next, back, first and last links at the bottom of each page. However, when the script is accessed remotely by the "include" the paging doesn't work. The navigation links display correctly at the bottom of the first page of results, but the next link just results in a "URL not found" error when selected. No PHP errors are displayed. I suspect the problem is in the code snippet below (although I'm not sure). This is the second query in the script, the first query goes after all the records that satisfy the search criteria. So I presume all those records are stored in an array. Yet the second query goes back to the database again to count the rows. In doing so the pagination seems to get left there and not make it to the remote client. Is there any way to get this second query to look at the array delivered by the first query and page on the client, rather than the server? Or is it just a lost cause? I'm not looking for specific coding, just whether it's possible to do what I'm trying to accomplish. Thanks.

 

Michael

 

// how many rows we have in database
$query   = "SELECT COUNT(field) AS numrows FROM table";
$result  = mysql_query($query) or die('Error, query failed');
$row     = mysql_fetch_array($result, MYSQL_ASSOC);
$numrows = $row['numrows'];
// how many pages we have when using paging?
$maxPage = ceil($numrows/$rowsPerPage);
$self = $_SERVER['PHP_SELF'];
...

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.