Jump to content

creating rss xml


caine

Recommended Posts

I'm currently working on creating the xml feed since I had data ready in my database after web data extraction. However, it has errors for this line:

 

<xml version="1.0" encoding="ISO-8859-1">

 

But my code seems no problem anyway?

 

<html>
<head>
<title>MMU RSS FEED</title>
</head>
<body>

header("Content-type: application/xml");


<xml version="1.0" encoding="ISO-8859-1">

<rss version ="2.0">


<channel>
<title>MMU RSS FEED Today: <?php echo date("D, d-M-Y H:i:s")?></title>
<link>http://bulletin.mmu.edu.my/</link>
<description>MMU RSS FEED</description>
<ttl>60<ttl>

<?php

//connect to database
$db = mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("bulletin", $db) or die(mysql_error());

$day = date("Y-n-j");  

//select queries
$sql = "SELECT * FROM `bul_data` WHERE `DATE` LIKE '{$day}%' ORDER by `DEPARTMENT`";
echo "sql=".$sql;

$res = mysql_query($sql) or die(mysql_error());

if(mysql_num_rows($res)>0)    
        {
              
                while($row=mysql_fetch_assoc($res))
                {
		$date = $row['DATE'];
		$title = $row['TITLE'];
		$department = $row['DEPARTMENT'];
		$link = $row['LINK'];

		//output to browser			
                   	
		echo "<item>";
		echo "<title>$title</title>";
		echo "<category>$department</category>";
		echo "<link><a href=\"$link\">$link</a></link>";
		echo "</item>";


	}

	echo "</table>";	

    	}

?>

</channel>
</rss>
</body>
</html>

 

Link to comment
https://forums.phpfreaks.com/topic/37039-creating-rss-xml/
Share on other sites

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.