Hello, I am creating a forum, using textfiles and directories.. wierd i know but i wanted to avoid databases... any way.
My problem is, is that i really want to page the forum so theres ten threads on each pagebut i am not using a database. here is the code i have to display posts from textfiles.
<?PHP
$forum1=$_GET["forum1"];
$forum2=$_GET["forum2"];
$pd=$_GET["postid"];
echo date("dmyhis", time());
echo "<BR>" . ceil($totalPages);
function RemoveExtension($strName)
{
$ext = strrchr($strName, '.');
if($ext !== false)
{
$strName = substr($strName, 0, -strlen($ext));
}
return $strName;
}
$forum1=$_GET["forum1"];
$forum2=$_GET["forum2"];
$postid=$_GET["postid"];
//define the path as relative
$path = "forums/$forum2/$forum1/$postid";
//using the opendir function
$dir_handle = @opendir($path) or die("Unable to open $path");
//running the while loop
while ($file = readdir($dir_handle))
{
if($file!=".." && $file!="." && $file!="lastpost.txt" && $file!="ts.txt")
if (isset($_GET["user"])){
$viewer=$_GET["user"];
}
else
{
$viewer="0";
}
if($file!=".." && $file!="." && $file!="lastpost.txt" && $file!="ts.txt"){
$lines = file("forums/$forum2/$forum1/$postid/$file");
echo "<div class='alpha'>
<div align='center' class='postInfo'><br /><br /><b>$lines[0]</b><br><br><a href='../../$lines[0]/1.php?viewer=$viewer'><img style='border:inset;' src='../../$lines[0]/p.jpg' width='100' height='100'></a>
</div>
<form><table width='580'>
<th align='left' class='postHeader'>
$lines[1] <input type='submit' value='Reply'>
</th>
<tr><td valign='top' align='left' class='postContent'>";
$lines = file("forums/$forum2/$forum1/$postid/$file");
for($i = 2; $i<count($lines); $i++)
{
echo $lines[$i] . "<br>";
}
echo "<br></td></table></div><br /></form>";
}
}
fclose($dir_handle);
?>
So inessence, i would like to page the results.. for say ten on each page.. any help is much appreciated!
Thanks in advanced!
PS. i hope ive made the problem clear.