Zdravim vedeli by ste mi poradit preco sa novsie komentare zobrazuju pod starsimi komentami ?
Chcel by som to aby bol novsi koment automaticky prvy a nie posledny.
zavisi to od tohto php kodu ?
Vopred dakujem za pomoc
Kód:
<?
if(!isset($_GET['page'])) {$_GET['page'] = 1;}
$page = $_GET['page'];
$xmlsrc = "comments.xml";
$xml = simplexml_load_file($xmlsrc);
$counted = count($xml);
function getComments(){
global $xml;
global $xmlsrc;
global $page;
$pagination = 20; // Number of posts on page
$i = 0; // comments index
foreach ($xml->comment as $comment) {
++$i;
if( (($page-1)*$pagination) < $i && $i <= ($page*$pagination) ) { // match page number to comments we want to show
echo '
<div class="commentwrap">
<div class="author"> <h4>';
if($comment->email != "")
{echo '<a href="mailto:'.htmlspecialchars($comment->email).'">'.htmlspecialchars($comment->name).'</a>';} // check if author supplied email - if so, show mailto: link
else { echo htmlspecialchars($comment->name); }; // else show only name
echo '</h3></div>
<div class="comment">'.nl2br(htmlspecialchars($comment->message)) .'</div>' // strip HTML - but preserve line breaks
.'</div>';
}
else {
if($i > ($page*$pagination)) { // add next page link (if more comments exist)
echo "<a class=\"pageplus\" href=\"?page="; echo $page+1; echo "#comments\">Novšie komenty »</a>"; break;
} // end next page link
}
} // end foreach
if ($page > 1) {echo "<a class=\"pageminus\" href=\"?page="; echo $page-1; echo "#comments\">« Staršie komenty</a>"; } // add link to previous pages (if not on page 1)
} // end getComments
?>