Version: 1.1

Type: Sample Code (HOWTO)

Category: Databases

License: GNU General Public License

Description: This little Script build the prev- , Pages- and next- Button for a given Select-Statement. More Infos can be found at : http://www.php-resource.de



Function next2prev($count) {
	global $offset, $limit;
	if($count == 0) {
		echo "<p>There are no messages to display.";
		exit;
	}
	$prev = $offset - 10;
	$newoffset = $offset + 10;
	if($offset == 0) { // am I on the first page yet?
		// I think I am :)
		if($newoffset < $count) {
			echo "<font style=\"font-family: verdana; font-size: 9pt; color: #ffffff; cursor: default;\">Previous</font> | ";
			slacker_link("$PHP_SELF?BID=$BID&offset=$newoffset", 'Next');
			echo "<br><br>";
		} else {
			echo "<font style=\"font-family: verdana; font-size: 9pt; color: #ffffff; cursor: default;\">Previous</font> | <font style=\"font-family: verdana; font-size: 9pt; color: #ffffff; cursor: default;\">Next</font>";			
		}
	}  else if($newoffset >= $count) { // am I on the first page?
		// looks like Im not
		// a prev link needs to be generated here
                slacker_link("$PHP_SELF?BID=$BID&offset=$prev", 'Previous');
		echo " | <font style=\"font-family: verdana; font-size: 9pt; color: #ffffff; cursor: default;\">Next</font>";
		echo "<br><br>";
	} else if($offset >= $limit) { // am I there yet?
		slacker_link("$PHP_SELF?BID=$BID&offset=$prev", 'Previous');
		echo " | ";
		slacker_link("$PHP_SELF?BID=$BID&offset=$newoffset", 'Next');
		echo "<br><br>";
	}
}