Page 1 of 1
Pagination Problems.
Posted: Sun Oct 31, 2004 3:47 pm
by MrSomeone
Hey.
I have an image that logs every hit to a text file.
Each line in the text file looks like this:
Now, what I want to do is have the file output into pages with
n amount of lines per page.
I thought I figured it out, however when I try to view the last few pages they are blank.
The working (not really) version can be viewed here:
http://mrsomeone.com/s/l.php
And the code here:
http://mrsomeone.com/s/l.phps
I've tryed multiple ways, and all of the tutorials I've seen are for PHP and MySQL, not a flat file DB.
I'm totally stumped, so any help would be greatly appreciated
-Someone
Posted: Sun Oct 31, 2004 4:51 pm
by John Cartwright
The only way I can see is by putting every line into an array.
Code: Select all
<?php
//num per page
$numpages = 25;
$array = file_get_contents('file.txt');
$array = explode("---whatever your seperator is---",$array);
if (empty($_GET['num']))
{
$_GET['num'] = 0;
}
?>
My ride just came so I have to go.. hope this gets you started... all you have to do is now simple math to calculate what to echo from the array, and then run a loop to echo them.
My advice, use a database.
Posted: Sun Oct 31, 2004 5:13 pm
by MrSomeone
The file is in an array, that's how I'm printing the results from the loop.
It's just that the pagination is messing up somewhere, just I can't seem to figure out where.
Posted: Mon Nov 01, 2004 8:35 pm
by MrSomeone
Anyone?
This is getting really annoying because I've gone over it multiple times.
(Don't just tell me to use a DB

)
Posted: Tue Nov 02, 2004 11:12 pm
by MrSomeone
Okay... Decided to use MySQL instead.
final product.
Posted: Wed Nov 03, 2004 2:50 am
by vigge89
just a small question, how did you convert the last numbers into *s?
i've been trying to do that but haven't succeeded, could you share yuor code?
thanks
Posted: Wed Nov 03, 2004 4:57 pm
by MrSomeone
The way I did it is [php_man]explode()[/php_man] the IP Address by "." and then whether or not I am logged in as admin it either masks or doesn't mask the IP:
Code: Select all
<?php
$ip = explode(".", $row['ip']);
if ($_GET['password'] == "") // If admin
$ip = $ip[0].".".$ip[1].".".$ip[2].".".$ip[3]; //Show full IP
else
$ip = $ip[0].".".$ip[1].".*.*"; // Show masked IP
?>
Posted: Thu Nov 04, 2004 7:56 am
by vigge89
MrSomeone wrote:The way I did it is [php_man]explode()[/php_man] the IP Address by "." and then whether or not I am logged in as admin it either masks or doesn't mask the IP:
Code: Select all
<?php
$ip = explode(".", $row['ip']);
if ($_GET['password'] == "") // If admin
$ip = $ip[0].".".$ip[1].".".$ip[2].".".$ip[3]; //Show full IP
else
$ip = $ip[0].".".$ip[1].".*.*"; // Show masked IP
?>
didn't think of that, thanks

Posted: Thu Nov 04, 2004 9:15 am
by timvw
And what happens if they have ipv6 address?

There is no need to re-build the string because you have it already in $row['ip']