Fetch articles only from certain catalog in rss.php

I have a rss.php for my web site which fetch all articles from all catalog and works fine
BUT NOW I want NOT all articles from all catalog I want only catalog " my_catalog_1"
I want fetch all articles from " catalog 1 "

here is my rss.php now (which work fine fetch all articles)

$sql = "SELECT * FROM carbon_topics ORDER BY id DESC LIMIT 20"; 
$query = mysql_query($sql) or die(mysql_error());
header("Content-type: text/xml"); 
echo "<?xml version='1.0' encoding='UTF-8'?> 
<rss version='2.0'>
<title>9lessons | Programming Blog </title>
<description>Programming Blog </description>
while($row = mysql_fetch_array($query))
echo "<item> 
echo "</channel></rss>"; 


here is my database (this database name is forum_catalog) this is the catalog it contains :" news , questions, help " and now I want only fetch articles from table(forum_catalog) =>news how to done that?


Image doesn’t show for me. I would suggest it will be a case of changing the query to something like

$sql = "SELECT * FROM carbon_topics WHERE forum_catalog='news' ORDER BY id DESC LIMIT 20"; 

but without seeing the table layout it’s hard to say.

You also need to look at updating your database calls to PDO rather than the old-style mysql functions you are using, when your host upgrades to PHP 7 it will stop working.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.