@kuau --
can you show us a sample of what your result set looks like? I think that would help clarify things.
About defining an array with only the rows you want, you certainly can do so. That's what Apache's first php block illustrates. As I mentioned, you can keep that array (instead of repeating the query on every request) by saving it to a session.
@ApacheTech --
right. so, say the pointer is currently at 0 (its starting position).
1. current( $art ) != reset( $art ) is FALSE.
2. skip to else{}, $prev = end( $art ). $prev will hold the last element of the array; that's what you wanted.
however, say the pointer is currently at 2 (maybe we used next() a few times).
1. current( $art ) != reset( $art ) is TRUE.
2. $prev = prev( $art ).
...*however*, reset() reset the pointer. when prev() is called, the pointer is at 0 again.
...$prev will hold FALSE, because you can't rewind the pointer past the beginning of the array.
to illustrate, try out these two variations:
PHP Code:
$art = array( 1,2,3,4,5);
if(current($art) != reset($art)) {
$prev = prev($art);
}else{
$prev = end($art);
}
var_dump( $prev );
// int(5)
PHP Code:
$art = array( 1,2,3,4,5);
next( $art ); // advance the pointer!
if(current($art) != reset($art)) {
$prev = prev($art);
}else{
$prev = end($art);
}
var_dump( $prev );
// bool(false)
Edit: boy, this thread is moving fast! 
Bookmarks