Version: 0.1
Type: Function
Category: Other
License: GNU General Public License
Description: This function dynamically creates a set of links including PREV/NEXT and page links for a set of articles in a directory. It simply requires that you place the files in a common directory and name them sequentially. Eg: step1.html, step2.html
Call the function with the value of the current page:
Example Usage:
<html>
<body>
<?
include (“functions.php”);
steps(1);
?>
function steps($cur) { $dir=opendir("includes"); $maxnum=0; $prev=$cur-1; $next=$cur+1; print "<table cellpadding=0 cellspacing=0 width=50%><tr>"; if ($cur > 1) { print "<td>"; print "<a href=index.php?action=6&file=step".$prev.".html>"; print "<img src=/images/prev.gif border=0></a> "; print "</td>"; } while($file = readdir($dir)) { if (ereg("^step([0-9]).html$",$file,$num)) { if ($num[1] > $maxnum) { $maxnum = $num[1]; } } } for($i=1; $i<=$maxnum; $i++) { if ($cur==$i) { print "<td>"; print "<font face=verdana,helvetica size=3><b>$i </b></font>"; print "</td>"; } else { print "<td>"; print "<a href=index.php?action=6&file=step".$i.".html>$i</a> "; print "</td>"; } } if (is_file("includes/step".$next.".html")) { print "<td>"; print "<a href=index.php?action=6&file=step".$next.".html> print "<img src=/images/next.gif border=0></a> "; print "</td>"; } print "</table>"; }