$filename = ""; //full path to filename
$pagelength = 10; //change this var for longer pages
if (isset($_GET['offset'])) //note that you should do some checking here to make sure the variable is clean
{
$offset = $_GET['offset'];
$newoffset = $offset + $pagelength;
}
else
{
$offset = 0;
$newoffset = $offset + $pagelength;
}
if (!file_exists($filename))
{ die ("database does not exist");}
//database exists
$fh = fopen ($filename, "r"); //the r mode is read only, pointer at the start of the file
while ($data = fgetcsv ($fh, 1024, "|")) // this line does most of the hard work. if you need longer than 1024 chars per line then increase the middle numeral [or use a proper database...]
{
if (count($data) >= $newoffset)
{
break; //exits the while loop
}
}
fclose ($fh);
// you now have $data populated with your db results.
print_r($data);
$newoffset
echo "<p><a href=\"$_SERVER[PHP_SELF]?offset=$newoffset\">Next Page</a></p>";