I found a script that looks fairly easy to implement...I just have two problems with it.
the xml that goes with it isCode:<?php $xml = simplexml_load_file('yourxml.xml'); $limit = 5; $page = $_GET['page']; foreach ( $xml->item as $item ) { if ( empty($page) ) { if ( $item->attributes()->page > 0 && $item->attributes()->page <= $page+$limit ) echo $item->attributes()->title,'<br/>'; } else { if ( $item->attributes()->page > ($page-1)*$limit && $item->attributes()->page <= (($page-1)*$limit)+$limit ) echo $item->attributes()->title,'<br/>'; } } ?>
My first problem is that my xml does not have a page# or ID (but I can add that)Code:<root> <item page="1" title="title 1" /> </root>
my big problem is that the pagination script does a foreach loop going from 1 to the end, while my script posts the data from last to first. How can I put them together?Code:<sayings> <message> <id></id> //can add this <vdate></vdate> <msgpost></msgpost> </message> </sayings>
ThanksCode:$i = count($xml->messages)-1; for($x=$i;$x>=0;$x--) { //reformat date $string = $xml->messages[$x]->vdate; $stringArray = explode("/", $string); $mydate = mktime(0,0,0,$stringArray[0],$stringArray[1],$stringArray[2]); $converteddate = date("F j, Y", $mydate); //write to page echo $converteddate.'<br /><p>' .$xml->messages[$x]->msgpost.'<hr></p>'; } ?>



Reply With Quote
Bookmarks