Question
Creating Next, Last, First & Previous links on an array.
I have a function that I am using a do>whille loop on a
recordset to give me distances and putting them in an array. I need
to sort that by the out putted data and displays them in groups of
10 (as you would do in a dating site).
First I've setup a recordset that I loop through to create the distance array:
do {
//CREATE THE ARRAY USING THE USERNAME FROM RECORDSET
$z['username'][$k] = $row_rsUSERIDID['username'];
//MY DISTANCE CALUATION FUNCTION
$z['distance'][$k++] = $totaldist;
} while ($row_rsUSERIDID = mysql_fetch_assoc($rsUSERIDID));
//SET NEW ARRAY
$z['user'] = $z['username'];
//SORT BY DISTANCES
natsort ($z['distance']);
reset ($z['distance']);
//DISPLAY ARRAY
foreach($z['distance'] as $k => $v){
$newuser = "{$z['user'][$k]}";
if ($v <= $dist_from) {
include("user.inc.php");
}
}
All this works fine, expect that I want to limit the number items in the arrary to 10 and have next, last, previous & first links on the page like you would with a recordset. Anyone have any ideas how to go about doing that?
Thanks
First I've setup a recordset that I loop through to create the distance array:
do {
//CREATE THE ARRAY USING THE USERNAME FROM RECORDSET
$z['username'][$k] = $row_rsUSERIDID['username'];
//MY DISTANCE CALUATION FUNCTION
$z['distance'][$k++] = $totaldist;
} while ($row_rsUSERIDID = mysql_fetch_assoc($rsUSERIDID));
//SET NEW ARRAY
$z['user'] = $z['username'];
//SORT BY DISTANCES
natsort ($z['distance']);
reset ($z['distance']);
//DISPLAY ARRAY
foreach($z['distance'] as $k => $v){
$newuser = "{$z['user'][$k]}";
if ($v <= $dist_from) {
include("user.inc.php");
}
}
All this works fine, expect that I want to limit the number items in the arrary to 10 and have next, last, previous & first links on the page like you would with a recordset. Anyone have any ideas how to go about doing that?
Thanks
