<?php header("Content-Type: text/xml; charset=utf-8");
echo "<?xml version=\"1.0\" ?>";
require_once("../dyci/common_functions.php");
require_once("../dyci/dbconnect.php");



$type = 2;
$title_count = 5;

$query = "SELECT id,title,summary FROM content_feeds WHERE type='$type' ORDER BY displaydate DESC LIMIT $title_count";
  
  $result = mysql_query($query);
  
  if ( $result ) {
    
    $num = mysql_num_rows($result);
    
	// "Location: http://" . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']) . "/" . "admin.php"  
	$about = "http://" . $_SERVER['HTTP_HOST'] . "/" . "events.xml";
	$link = "http://" . $_SERVER['HTTP_HOST']."/";
    
?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/">
  <channel rdf:about="<?=$about?>">
    <title>Current events at Don Bosco Institute of Technology</title>
    <link><?=$link?></link>
    <description>
    Website of Don Bosco Institute of Technology, Kurla
    </description>
    <items>
      <rdf:Seq>
      <?
      for ( $i = 0 ; $i < $num ; $i++ ) {
      
      $row = mysql_fetch_array($result);
      ?>
          <rdf:li resource="<?echo $link."events.php?type=".$type."&amp;start=".$row['id'];?>" />
      <?
      }
      ?>
      </rdf:Seq>
    </items>
  </channel>
<?php

  }


$query = "SELECT id,title,summary,UNIX_TIMESTAMP(displaydate) as displaydate FROM content_feeds WHERE type='$type' ORDER BY displaydate DESC LIMIT $title_count";
  
  $result = mysql_query($query);
  
  if ( $result ) {
    $num = mysql_num_rows($result);
    
    for ( $i = 0 ; $i < $num ; $i++ ) {
      
      $row = mysql_fetch_array($result);
      
      ?>
      <item rdf:about="<?echo $link."events.php?type=".$type."&amp;start=".$row['id'];?>">
      <title><?print htmlentities($row['title'],ENT_QUOTES);?></title>
      <link><?echo $link."events.php?type=".$type."&amp;start=".$row['id'] ?></link>
      <description>
        <?print htmlentities($row['summary'],ENT_QUOTES);?>
      </description>
      <pubDate><?print strftime("%a, %d %b %Y %T %Z",$row['displaydate']); ?></pubDate>
      </item>
      
      <?
            
      }
  }
    
  
?>
  
</rdf:RDF>


