amwassil Posted February 18, 2008 Share Posted February 18, 2008 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']; ... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.