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)

<?php
include('connect.php');
 
 
$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'>
<channel>
<title>9lessons | Programming Blog </title>
<link>http://example.com</link>
<description>Programming Blog </description>
<language>en-us</language>"; 
 
while($row = mysql_fetch_array($query))
{
$Topic=$row['Topic']; 
$ID=$row['ID']; 
 
echo "<item> 
<title>$Topic</title>
 
<link>http://example.com/t/$ID</link>
</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?

http://bbs.168nyc.com/upload/image/20160131/1454182383549301.png

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.