PHP, MySQL and RSS

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
kerepuki
Forum Commoner
Posts: 30
Joined: Fri Oct 29, 2004 12:28 am

PHP, MySQL and RSS

Post by kerepuki »

Hey everyone!

I have a problem, I am creating an RSS feed to my site however, I have 2 tables...lets call them table_one and table_two. Each has there own primary key.

table_two has multiple records relating to table_one (one to many). I want to create a feed where I loop though table_one and pull out all the records but group all related records that are in table_two.

Can this be done for RSS? I know RSS is suppose to be a summary type system with a link but I want to be able to read all items related to another...if any of that makes sense.

Any suggestions or help or sample code would be great!

Thanks
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP, MySQL and RSS

Post by requinix »

Databases and RSS are completely different. Completely different.

What you're concerned about can be dealt with in your SQL query. Then your PHP code generates the RSS feed.
kerepuki
Forum Commoner
Posts: 30
Joined: Fri Oct 29, 2004 12:28 am

Re: PHP, MySQL and RSS

Post by kerepuki »

Hi, thanks for the reply. I realise the difference however I am trying to do a nested while loop inside the generated XML.

Can this be done?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: PHP, MySQL and RSS

Post by requinix »

kerepuki wrote:Hi, thanks for the reply. I realise the difference however I am trying to do a nested while loop inside the generated XML.

Can this be done?
As you're saying it? No. XML doesn't have loops.
kerepuki
Forum Commoner
Posts: 30
Joined: Fri Oct 29, 2004 12:28 am

Re: PHP, MySQL and RSS

Post by kerepuki »

Hi, thanks again for your reply.

I am using PHP to generate the XML and my php script has a loop, 2 infact.

I have worked it out. I was looping through my result set and I had the tag in the wrong place. It was inside the loop when it needed to be outside the loop.

i.e.

while($row = mysql_fetch_array($data)){

$quotequery = mysql_query("SELECT * FROM tbl_quote WHERE post_id = '" . $row['post_id'] . "'");

echo("<item>");

echo("<title>".$row[post_title]."</title>");
echo("<description>");
while($quoteresult = mysql_fetch_array($quotequery)){
echo($quoteresult['quote']);
echo($quoteresult['quote_id']);
}
echo("</description>");
echo("</item>");
}

if anyone wants to know
Post Reply