MySQL table and want to build a XML file with it in order to make a RSS feed.

  
  <?php   $dom = new DOMDocument() ; include "connection.php"; $queryz = "SELECT * FROM ticker"; $resultz = mysql_query($queryz) or die('Error, query failed'); $row = mysql_fetch_assoc($resultz); $rss = $dom->createElement('rss'); while($row = mysql_fetch_array( $resultz )) {     $item = $dom->createElement("item");     $item->appendChild($dom->createElement("title", $row['item_title']));     $item->appendChild($dom->createElement("pubDate",$row['item_pubDate']));     $item->appendChild($dom->createElement("description",$row['item_description']));     $item->appendChild($dom->createElement("link",$row['item_link']));     $rss->appendChild($item); } $dom->appendChild($rss); $dom->save("myxml.xml");
  
  
  
  OR
  
<?php header('Content-Type: text/xml; charset=UTF-8');   $dom = new DOMDocument() ;  include "connection.php"; $queryz = "SELECT * FROM ticker"; $resultz = mysql_query($queryz) or die('Error, query failed'); $row = mysql_fetch_assoc($resultz); while($row = mysql_fetch_array( $resultz )) { $tit = $dom->createElement("title", $row['item_title']) ; $pub = $dom->createElement("pubDate",$row['item_pubDate']) ; $des = $dom->createElement("description",$row['item_description']) ; $lnk = $dom->createElement("link",$row['item_link']) ;        $dom->appendChild($tit) ;        $dom->appendChild($pub) ;       $dom->appendChild($des) ;       $dom->appendChild($lnk) ;  }  $dom->save("myxml.xml") ;  ?>


RSS Display
<?php include('rss-feed-reader.php');   $feed = 'http://www.domain.com/feed.xml'; $max_items = 5; $rss = new mod_rss(); $rss->parser($feed, $max_items, true);  ?>

Comments

Popular posts from this blog

உடல் அறிகுறிகள், வலிகள் மற்றும் அவற்றின் சிகிச்சைகள்: வீட்டு சிகிச்சைகள் மற்றும் அக்குபிரஷர் புள்ளிகள்

REST / AJAX calls from within a Jaggery script