Welcome to WebmasterWorld Guest from 54.166.178.177

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

i have PHP script how i can creat RSS , help me please

     
4:38 am on Apr 10, 2010 (gmt 0)

5+ Year Member



hi dear

i have i small open soruce php script its can show the titles like this .

<?
$query = "SELECT * FROM roseNews where newscat in(4)ORDER BY newsdate DESC,newsid DESC limit 5" ;
$result= mysql_query($query);
if(!$result)echo mysql_error();
while($row=mysql_fetch_array($result))
{
$id= $row["newsid"];
$date = $row["newsdate"];
$title= $row["newsheadline"];
?>
<?
echo "<div>$date</div><div><A class=Afghannews href='details.php?id=$id'>$title</A></div>";
?>
<?}?>
</div>


so have i creat i RSS for that , i try like this
<?xml version='1.0' encoding='utf-8'?>
<?php
$query = "SELECT * FROM roseNews where newscat='44' ORDER BY newsdate DESC,newsid DESC limit 18" ; $result= mysql_query($query); if(!$result)echo mysql_error(); while($row=mysql_fetch_array($result)){
$id= $row["newsid"];
$date = $row["newsdate"];
$title= $row["newsheadline"];
}?>
<rss version='2.0' xmlns:dc='http://purl.org/dc/elements/1.1/'>
<channel>
<title>MY world</title>
<link>rss.php</link>
<description>Latest Posts at example.com</description>
<language>ar-sa</language>
<item>
<pubDate>{$date}</pubDate>
<title>{$title}</title>
<link>details.php?id=$id</link>
<guid>details.php?id=$id</guid>
<description>summary of the post</description>
</item>

</channel>
</rss>


but its dosnt work

pleasse write for me the coract codes

[edited by: eelixduppy at 2:51 pm (utc) on Apr 12, 2010]
[edit reason] exemplified [/edit]

4:35 am on Apr 12, 2010 (gmt 0)

WebmasterWorld Administrator httpwebwitch is a WebmasterWorld Top Contributor of All Time 10+ Year Member



What you've got there is full of problems

There's a while loop which assigns values to $id and $date and $title, but I'd expect you want the same loop to create your <item> nodes. It's not doing that.

also, putting {$date} around a variable name doesn't print the value of $date.

I'm going to move this post over to the PHP forum
 

Featured Threads

Hot Threads This Week

Hot Threads This Month