Dustin013 Posted June 18, 2008 Share Posted June 18, 2008 Basically queries were slowing my site down so I setup a php script to query the site every 15min. The queried information is dumped into XML files containing thousands of entries... I did this because now the users simply read off the XML files without searching the database every time a page is requested. With SQL queries I was able to create separate pages for every "however many" topics listed... basically 50 post where displayed per page and there where Previous and Next buttons. I have been reading most the day and I still can't tackle this problem. I would like to take the code below and tell it to only list 50 (or whatever number I assign the variable) results per page... with a next and previous button... However, since its XML and I cannot query the database I am simply at a loss... Does anyone know a good site I could read about doing something like this when using PHP to display the contents of an XML file? <?php include("header.php"); include 'include/determaincategory.php'; ?> <div class="box2"> <!-- START Listings --> <h1><span class="green"><span class="white">Listing all topics...</span></h1> <strong> <?php include 'include/config.php'; include 'include/connect.php'; mysql_select_db($dbname); include 'include/determaincategory.php'; $pFile = new SimpleXMLElement($querycategoryxmlbig, null, true); foreach ($pFile->channel as $pChild) { foreach ($pFile->channel->item as $pItem) { echo "$pFile"; foreach ($pItem->children() as $pChild) { switch ($pChild->getName()) { case 'title': echo "<b>$pChild</b></a></blockquote>\n"; break; case 'link': printf('<blockquote>- <a href="%s">' , $pChild); break; } } } } ?> </strong> </div> <!-- END Listings --> <?php include("footer.php"); ?> Link to comment https://forums.phpfreaks.com/topic/110674-display-contents-of-xml-file-in-pages-with-php/ Share on other sites More sharing options...
bluejay002 Posted June 18, 2008 Share Posted June 18, 2008 you can use for() instead of foreach() to trail the index you want to start with. Link to comment https://forums.phpfreaks.com/topic/110674-display-contents-of-xml-file-in-pages-with-php/#findComment-567773 Share on other sites More sharing options...
DarkWater Posted June 18, 2008 Share Posted June 18, 2008 I seriously doubt that the queries were slowing your site down more than half a second. You had to have been doing something really wrong to get something like that to happen. Link to comment https://forums.phpfreaks.com/topic/110674-display-contents-of-xml-file-in-pages-with-php/#findComment-567774 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.