This module prints a common split href menu, like those used to
display into several pages the results of a search engine.
For example, you have a page results.php3 that prints a collection
of results, and for more convenience you want to write several pages
from this result, each grouping MAXHIT results. So you paste this code
into a file split.php3, then you write in results.php3: include("[...]/split.php3");
at the exact location where you want the split bar to display.
Don't forget to modify your results page results.php3 to display
only the results i to i+MAXHIT-1 !
***
A live example can be seen at http://tropicalm.free.fr/pub/world/gallery/gallery.php3
***
*******************************************************************************
Code of split.php3:
*******************************************************************************
arguments: _maxelmt: number of elements in the collection
MAXHIT : number of max hits for a page
p : current page to be seen
cat (optional): optional parameters to send at return
<?
/*if MAXHIT=0 print a message error*/
if(!$MAXHIT) {
print "MAXHIT=0 : no split available!\n";
}
/*bypass if there's no more than one page*/
if ($_maxelmt> $MAXHIT) {
/* pattern: Results i'-i'+MAXHIT [<<Prev] | 1 --page+1 [2 --page+2 ...] | [Next>>] Page
i of n */
/*<<Prev*/
/*if p > 1, Prev is active, otherwise it's not*/
print "\t\t<font face='Arial' size='1'";
/********************************************************************************
Example of use in results.php3: 9 hits maximum, in a 3*3 table
Note: the colspans of <td> may not be correct as I adapted this example
from another presentation
********************************************************************************/
<?
/*place here your code to query MySQL database...*/
/*if more than MAXHIT results are found, split the results into several pages*/
$i=$MAXHIT*$p;
/* --> $p is initialized to 0 if results.php3 is 1st called, but then it gets its value
from split.php3!*/
print " <table border='0'>\n";
print " <tr>\n";
print " <td>\n";
/*remind query or show a sorry message if no result was found:*/
print "Your query: $qry.\n";
print " </td>\n";
print " </tr>\n";
print "\t\t$number result$plural $pluralbe found for this query\n";
print "\t\t<hr size='1'>\n"; print "\t </td>\n"; print "\t </tr>\n";
print "\t <tr>\n";
print "\t <td>\n";
/*category of result page to show when returning from split module*/
$cat= "[optional parameters]";
$urlinfo= "p=$p&_maxelmt=$number&MAXHIT=$MAXHIT&cat=".$cat;
/*if table didn't end in a full row, append end of row*/
if ($i % 3) {
print "\t\t </tr>\n";
}
print "\t\t</table>\n";
print "\t </td>\n";
print "\t </tr>\n";
} /*end if $number*/
else {
print "\t <tr>\n";
print "\t <td>\n";
/*sorry message*/
print "\t\tSorry, no result was found in the database\n";
print "\t </td>\n";
print "\t </tr>\n";
}