22 Replies - 8508 Views - Last Post: 06 June 2005 - 04:19 PM
#1
Pagination in PHP & MS Access
Posted 01 June 2005 - 10:25 AM
Does anyone know how I can do this as all the tutorials I have found have been for PHP with mySQL.
Thanks
Rebecca.
Replies To: Pagination in PHP & MS Access
#2
Re: Pagination in PHP & MS Access
Posted 01 June 2005 - 11:34 AM
#3
Re: Pagination in PHP & MS Access
Posted 01 June 2005 - 12:40 PM
What do you suggest?
#4
Re: Pagination in PHP & MS Access
Posted 01 June 2005 - 01:01 PM
Also, depending on how your primary/unique key is setup, you can often times do a WHERE id >= x AND id <= y where x and y are your ranges. Problem with that is, they must be in order and if you skip ID's you'll end up with less than the number of records you want.
#5
Re: Pagination in PHP & MS Access
Posted 01 June 2005 - 01:04 PM
Say you have your page numbers and you're doing 10 records per page, you would have something like this:
<- Previous | 1 | 2 | 3 | Next ->
Each link would have ?start=x&end=y with 1,10;11,20;21,30 respectively. Then in your loop in the PHP you would loop from $start to $end.
#6
Re: Pagination in PHP & MS Access
Posted 01 June 2005 - 03:57 PM
Not sure about MS Access...but...here is a SQL example. (Not sure if it's standard SQL though. It may have MySQL elements.) I use a similar system for my blog archives at josherickson.org.
$page = (int) (isset($_GET['page'])) ? $_GET['page'] : 1;
$limit = 10;
$offset = $limit*($page-1);
$query = "SELECT * FROM table WHERE 1 ORDER BY `id` ASC LIMIT {$limit} OFFSET {$offset};";
So if $page equals 1, then we will get back rows 0-9 (e.g. entries 1-10).
This post has been edited by hotsnoj: 01 June 2005 - 04:01 PM
#7
Re: Pagination in PHP & MS Access
Posted 01 June 2005 - 04:02 PM
#8
Re: Pagination in PHP & MS Access
Posted 01 June 2005 - 04:12 PM
http://docs.codechar...ptimizeSQL.html ?
#9
Re: Pagination in PHP & MS Access
Posted 02 June 2005 - 02:23 AM
$page = (int) (isset($_GET['page'])) ? $_GET['page'] : 1; $limit = 10; $offset = $limit*($page-1); $strSQL = "SELECT TOP $limit,$offset * FROM property.......
If I take out the $offset in the SQL statement then my results are limited to 10 but if I leave it in I get all the records with no limits!
Thanks
Rebecca.
#10
Re: Pagination in PHP & MS Access
Posted 02 June 2005 - 03:33 AM
#11
Re: Pagination in PHP & MS Access
Posted 02 June 2005 - 01:39 PM
#12
Re: Pagination in PHP & MS Access
Posted 02 June 2005 - 04:09 PM
Also how would I go about counting the number of rows? I tried using COUNT in the SQL statement but cannot get the result to print in a variable.
#13
Re: Pagination in PHP & MS Access
Posted 04 June 2005 - 05:52 AM
What code are you using and not getting the count?
#14
Re: Pagination in PHP & MS Access
Posted 05 June 2005 - 08:44 AM
$strSQL = "SELECT * FROM property WHERE propertytype = '".$propertyrequired."' AND area='".$area."' AND bedrooms = '".$bedrooms."' AND price <= '".$budget."' ORDER BY '".$address3."'"; $resultcount = "SELECT COUNT(propertyID) FROM property WHERE propertytype = '".$propertyrequired."' AND area='".$area."' AND bedrooms = '".$bedrooms."' AND price <= '".$budget."' ORDER BY '".$address3."'";
So what I have tried to do is run the first SQL statement to get the results then run the second based on the first to count the results. When I run the second the code is:
$rs2 = $conn->execute($resultcount);
When I try to print the value of $rs2 I just get 'Object' rather than the value.
I am sure I am just approaching this the wrong way!
Thanks
Bex.
#15
Re: Pagination in PHP & MS Access
Posted 05 June 2005 - 08:53 AM
http://us2.php.net/m...ql-num-rows.php
You'll probably wanna use the mysql_fetch_array() function to bring back everything in to an array, then loop through to do your pagination.
|
|

New Topic/Question
Reply



MultiQuote




|