PDA

View Full Version : guestbook issue


althalus
08-27-2004, 09:37 AM
i have a guestbook script, where part of it looks like:
<?php
$fileName = file ("log.txt");
$rows = count ($fileName);

if ($rows > 10)
{
if (!isset ($row) )
{ $row = 0; }

if ($row > 0)
{ echo "[<a href=\"index.php?p=main&row=" . ($row - 10) . "\"> +10 </a>]<br>"; }

if ( ($rows - $row) > 10)
{ echo "[<a href=\"index.php?p=main&row=" . ($row + 10) . "\"> -10 </a>]<br>"; }

for ($i = $row; $i < ($row + 10); $i++)
{ echo $fileName [$i]; }
}
else
{ for ($i=0; $i < $rows; $i++)
{ echo $fileName [$i]; }
}
?>

it prints out links to a "new page" if there's more than 10 entries on the page. the link ends up on top of the messages, but i'd like to have the links on the bottom. tried fiddling aroudn with it some, but i'm not that good with php so it told me the ELSE was in the wrong spot. any help appreciated! :)

scoutt
08-27-2004, 11:35 AM
it has nothing to do with php, you have to put it in a table or something. it is on;y putting it in the spot you told it to.

althalus
08-27-2004, 02:29 PM
i'm not sure i follow there, but it has to be somewhere in this code, as this is the only lines that deal with the links between each post.

i tried moving the line { echo $fileName [$i]; } to above the if and that's when it told me the ELSE was in the wrong spot.

the links are echoed by the code, and i should be able to have them echoed after $FileName is echoed, right? the question is how...

i have no logic... :rolleyes:

scoutt
08-27-2004, 03:01 PM
if that code is above the table of course it will insert it above. if it is in the table but not in a cell then it will put it above, if it is below the table then it should be below the table if the table is closed prior.

what is the other code in that page?

althalus
08-27-2004, 03:11 PM
that's all there is on that page. i have three pages, one with the form. one that processes the textfile, adding the new lines and one (this one) that prints out 10 lines from the textfile.

added: if you look here (http://www.magnusandgeorgia.tk) you can see what i mean. the [-10] leads to the next 10 lines backwards in the textfile.

scoutt
08-27-2004, 03:40 PM
ok, if you want it after all this

27 08 2004 bump!
27 08 2004 bump!
27 08 2004 bump!
27 08 2004 bump!
27 08 2004 bump!
27 08 2004 bump!
27 08 2004 bump!
27 08 2004 bump!
27 08 2004 bump!
27 08 2004 bump!

than you need to include all that code above after it.

althalus
08-28-2004, 04:26 AM
i got it, finally. moved the
for ($i = $row; $i < ($row + 10); $i++)
{ echo $fileName [$i]; } to above the
if (!isset ($row) ) line. as i said, i'm not very good with php, but i try to learn slowly by modifying scripts that don't look very "heavy", but clearly are.. heh.

thanks for the help, scoutt :)

added: and yes, i plan on getting into it on a bigger level one day. might buy a book on the subject :)