Skip to main content
Known Participant
December 11, 2006
Question

Creating Next, Last, First & Previous links on an array.

  • December 11, 2006
  • 2 replies
  • 341 views
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
This topic has been closed for replies.

2 replies

VernManAuthor
Known Participant
December 12, 2006
That would be beautiful if there was an extension I could use, but according to Tom this would not suit my needs. This requires some hand coding that is a little beyond me. Problem is his extension only works with recordsets that Dreamweaver has created. I am creating an array from a recordset and now need to create a navigation tool based on the arrary and not the recordset.

Anyone else?
Inspiring
December 11, 2006
On Mon, 11 Dec 2006 17:10:17 +0000 (UTC), "VernMan"
<webforumsuser@macromedia.com> wrote:

> 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?

I use this extension by Tom Muck - very good value.

http://www.tom-muck.com/extensions/help/RecordsetNavigationSuite/

--
Steve
steve at flyingtigerwebdesign dot com