Jump to content

Need help understanding this snippet.


codeboy89

Recommended Posts

I am trying to remove the paging system from this snippet, it displays XML data into pages according to the $posts variable. How would I simplify this code (remove whats not needed) and show just everything on 1 page. I keep getting errors. Thanks for any help

 

 

<?
$file = implode('', file ("post.xml"));

{


// Max amount of posts on one page
$posts = 6;

// Count the number of posts
$foo = preg_split ("<.*ponmurt.*>", $file);
$count = (count($foo)-1)/2;
$pages = intval(($count-1)/$posts)+1;

$page = intval($_GET["page"]);
// Always begin at the last page
if($page < 1 || $page > $pages)
  $page = $pages;

// Write the required page numbers
if($pages > 1) {
  print "<p>page ";
  for($i=$pages; $i>=1; $i--)
    if($i == $page)
      print " <b><font size = \"3\">$i</b></font> ";
    else
      print "<a href=index.php?page=$i> $i </a>";
  print "<hr ALIGN = CENTER WIDTH = 70%>";
  print "<br/></p>";
}

$start = ($page-1) * ($posts*2) + 1;
for($i=$start; $i<$start+$posts*2; $i+=2)
  print $foo[$i];

// Write the required page numbers
if($pages > 1) {
  print "<p>page ";
  for($i=$pages; $i>=1; $i--)
    if($i == $page)
      print " <b><font size = \"3\">$i</b></font> ";
    else
      print "<a href=index.php?page=$i> $i </a>";
  print "<hr ALIGN = CENTER WIDTH = 70%>";
  print "<br/></p>";
}
}
?>

Link to comment
https://forums.phpfreaks.com/topic/191219-need-help-understanding-this-snippet/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.