0 ) { $SQL .= ' WHERE '.join(' AND ', $WHERE); } # Execute Query, if error = die(), else continue on if( ( $res = mysql_query($SQL, $ftn) ) === false ) { die(mysql_error($ftn)); } # Initalize the $records holder array $records = array(); # Get the size of the result set $total_records = mysql_num_rows($res); # Initialize some variables so they don't give us fits latter $first = $prev = $next = $last = false; # Did I get any results back? Yes = Good, let figure out where I'm at and grab the # correct portion of the results and create the settings for the pagination links if ( $total_records > 0 ) { # How many results per page? $limit_per_page = 10; # What page do you want me to start on by default? $pageNum = 0; # Was a pageNum given to me AND is it an integer? if ( is_int($_GET['pageNum']) ) { # Set the pageNum to the submitted number # I know, a little redundent, CYA always!!! $pageNum = (int)$_GET['pageNum']; } # Calculate the total number of pages there would be $total_pages = ceil( $total_records % $limit_per_page ); # See if we are on the first page, NO, then set the $first and $prev settings if ( $pageNum != 0 ) { $first = TRUE; $prev = ( $current_page - 1 ); } # See if we are on the last page, NO, then set the $next and $last settings if ( $current_page < $total_pages ) { $next = ( $current_page + 1 ); $last = $total_pages; } # Find my starting point.. I seem to recal that mysql_data_seek needs a starting # point of 1 or greater, otherwise it freaks $starting_point = ( ( $pageNum * $limit_per_page ) + 1 ); # Move the internal point for the result set to where we need it mysql_data_seek($res, $starting_point); # Loop and grab the data for ( $i = 0 ; $i < $limit_per_page; $i++ ) { $records[] = mysql_fetch_assoc($res); } } # Free it all, we are done with the results... mysql_free_result($res); ?>
First" : ' ' ); ?> | Previous" : ' ' ); ?> | Next" : ' ' ); ?> | Last" : ' ' ); ?> |