How can I split my guestbook into multiple pages? I have next/previous links, but they doesn't work. Code I used:and live example: http://www.taikasilma.com/projects/test.htmlCode:<html> <head><title>Vieraskirja</title> <style type="text/css"> a:link, a:visited:link, a:visited { font-family:Verdana; font-size:8pt; color:#21BAC1 } * { font-family:Verdana; font-size:8pt; } </style> </head> <body> <div align="center" style="text-align:center"><center><table border="0" width="400" cellpadding="0" cellspacing="0"> <tr> <td style="font-family:Verdana; font-size:8pt" colspan="2"> Lue - <a href="write.php" style="color:#21BAC1">Kirjoita</a><br/><br/> </td> </tr> <tr> <td colspan="2" bgcolor="#DCECF2" style="background-color:#DCECF2; height:3px" height="3"></td> </tr> <?php $rovit = 20; $file = file("ol.txt"); $file = array_reverse($file); $i = 0; foreach ($file as $key => $value) { if ($i < $rovit) { $viesti = explode("|", $value); echo "<tr><td style=\"padding-top:10px\" colspan=\"2\"><span style=\"font-family:Verdana; font-size:8pt; color:#000000; font-weight:bold\">$viesti[1]</span> - <a href=\"mailto:$viesti[2]\" style=\"color:#21B4C1; font-family:Verdana; font-size:8pt;\">email</a> - <a href=\"$viesti[3]\" style=\"color:#21B4C1; font-family:Verdana; font-size:8pt;\">www</a></td><tr></tr><td width=\"20\"></td><td style=\"padding:2px; font-family:Verdana; font-size:8pt; background-color:#E8F5F9\">$viesti[4]<br/><div align=\"right\" style=\"text-align:right; font-family:Verdana; font-size:7pt;\">Lähetetty: $viesti[0]</span></td></tr>\n"; } $i++; } $num = count($file); $sivuN = 1; if(isset($_GET["sivu"])) { $sivuN = $_GET["sivu"]; } $max = ceil($num/$rovit); $self = $_SERVER["PHP_SELF"]; $navi = ""; for($sivu = 1; $sivu <= $max; $sivu++) { if($sivu == $num) { $navi .= " $sivu "; } else { $nav .= " <a href=\"$self?sivu=$sivu\">$sivu</a> "; } } if($sivuN > 1) { $sivu = $sivuN - 1; $edell = " <a href=\"$self?sivu=$sivu\"><</a> "; $eka = " <a href=\"$self?sivu=1\">|<<</a> "; } else { $edell = "<"; $eka = "|<<"; } if($sivuN < $rovit) { $sivu = $sivuN + 1; $seur = " <a href=\"$self?sivu=$sivu\">></a> "; $viim = " <a href=\"$self?sivu=$max\">>>|</a> "; } else { $seur = " > "; $viim = " >>| "; } echo $eka . $edell . $navi . $seur . $viim; ?> </table></center></div> </body> </html>
Thanks in advance.



Reply With Quote
Bookmarks