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
PHP, MySQL and RSS
Moderator: General Moderators
Re: PHP, MySQL and RSS
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.
What you're concerned about can be dealt with in your SQL query. Then your PHP code generates the RSS feed.
Re: PHP, MySQL and RSS
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?
Can this be done?
Re: PHP, MySQL and RSS
As you're saying it? No. XML doesn't have loops.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?
Re: PHP, MySQL and RSS
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
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