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 '."\n"; } /*bypass if there's no more than one page*/ if ($_maxelmt> $MAXHIT) { /* pattern: Results i'-i'+MAXHIT [<>] Page i of n */ /*< 1, Prev is active, otherwise it's not*/ print "\t\t<<Prev | \n"; } /*light gray*/ else { /*prev*/ $prevpage=$p-1; $anurl = "results.php3?_maxelmt=$_maxelmt&MAXHIT=$MAXHIT&p=$prevpage&$cat"; print " color='#008000' ><<Prev | \n"; } print "\t\t"."\n"; /*print a page number every MAXHIT*/ for($i=0;$i<$_maxelmt;$i+=$MAXHIT) { /*page number i+1*/ $pi=($i/$MAXHIT)+1; /*don't activate current page's href*/ if($pi==$p) { print "$pi "; } else { $anurl = "results.php3?_maxelmt=$_maxelmt&MAXHIT=$MAXHIT&p=$pi&$cat"; print "\n"; print "\t\t".$pi.' '."\n"; } print "\t\t"."\n"; } /*Next>>*/ /*if p*MAXHIT doesn't meet or exceed MAXHIT, Next is active, otherwise it's not*/ print "\t\t| Next>>\n"; } /*light gray*/ else { /*next*/ $nextpage=$p+1; $anurl = "results.php3?_maxelmt=$_maxelmt&MAXHIT=$MAXHIT&p=$nextpage&$cat"; print ">| Next>>\n";} print ''; } if($_maxelmt) { print "\t\t Page ".$p.' of '.ceil($_maxelmt/$MAXHIT).''."\n"; } } /*if ($_maxelmt> $MAXHIT) } /*end lse if(!$MAXHIT)*/ ?> /******************************************************************************** Example of use in results.php3: 9 hits maximum, in a 3*3 table Note: the colspans of may not be correct as I adapted this example from another presentation ********************************************************************************/ $p is initialized to 0 if results.php3 is 1st called, but then it gets its value from split.php3!*/ print " \n"; print " \n"; print " \n"; print " \n"; if($number) { print "\n\t \n"; print "\t \n"; if($number>1) { /*split header*/ $plural='s'; $pluralbe='were'; } else { $plural=''; $pluralbe='was'; } /*displays details about results*/ print "\t\t$number result$plural $pluralbe found for this query\n"; print "\t\t
\n"; print "\t \n"; print "\t
\n"; print "\t \n"; print "\t \n"; print "\t \n"; print "\t \n"; } /*end if $number*/ else { print "\t \n"; print "\t \n"; print "\t \n"; } print "
\n"; /*remind query or show a sorry message if no result was found:*/ print "Your query: $qry.\n"; print "
\n"; /*category of result page to show when returning from split module*/ $cat="[optional parameters]"; $urlinfo="p=$p&_maxelmt=$number&MAXHIT=$MAXHIT&cat=".$cat; /*calling split module*/ "http://[your path]/split.php3?$urlinfo&res=1"; print "\t
\n"; print "\t\t\n"; /*default recordset scanning is 0 to MAXHIT-1 (p=1)*/ $i=$MAXHIT*($p-1); while ($i<$MAXHIT*$p && $i < $number) { $mVar1=mysql_result($result,$i,"Var1"); $mVar2=mysql_result($result,$i,"Var2"); /*etc...*/ $index=$i+1; /*format table*/ if (!($i % 3)) { print "\t\t \n"; } $mName="$mVar1/$mVar2.html"; /*for instance...*/ print "\t\t \n"; if (($i % 3) == 2) { print "\t\t \n"; } /*next record*/ $i++; } /*end while*/ /*if table didn't end in a full row, append end of row*/ if ($i % 3) { print "\t\t \n"; } print "\t\t
\n\t\t\t\n"; print "\n\t\t
\n"; print "\t
\n"; /*sorry message*/ print "\t\tSorry, no result was found in the database\n"; print "\t
\n"; ?>