Hi!
Can anybody please help me with this?
I use a guestbook called slimBook, that I really like because of its compact size (kind of anticipated in the name, dont you think? 🙂 )
Anyway, it lists the posts ascending, that is, the most recent post appears at the bottom of the list. How can I change the code below so that the posts are listed in a descending way? The list is stored in a flatfile in .xml format.
Regards,
Patrick
"<?php
// Get the file
$file = implode('', file ("post.xml"));
// Check if request is a post or not
if ($post == "yes")
{
print "
<form action=post.php method=post>
<input type=hidden name=post value=yes>
<p>
Namn<br>
<input type=text name=name size=30>
</p>
<p>
Meddelande<br>
<textarea name=message rows=5 cols=50></textarea>
</p>
<p>
<input type=reset value=Återställ>
<input type=submit value=Skicka>
</p>
</form>";
}
else
{
print "
<p>
<a href=index.php?post=yes><b>> Skriv ett inlägg</b></a><br>
</p>
";
// Max amount of posts on one page
$posts = 10;
// Count the number of posts
$foo = preg_split ("<.post.>", $file);
$count = count($foo);
$posts = ( $posts * 2);
$pages = ($count / $posts);
// Always begin at the last page
if ( $page == "") {
$page = 0;
while ( $page < $pages) {
++$page;
}
}
// Write the required page numbers
$i = 0;
print "<p>";
if ( $count > $posts) {
print "page ";
while ( $i < $pages) {
++$i;
if ( $page == $i) {
print " <b>$i</b> ";
}
else {
print "<a href=index.php?page=$i> $i </a>";}
}
}
print "</p>";
// Write the posts one by one
$i = (($page - 1) $posts);
$to = ( $page $posts);
while ( $i < $to)
{
$post = $foo[$i];
print "$post";
$i++;
}
}
?>"