Jump to content

Display contents of XML file in pages with PHP


Dustin013

Recommended Posts

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"); ?>

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.