Jump to content

rss.php


Eddie01001

Recommended Posts

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>
<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>
 
</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? 

 

1454182383549301.png

 

Link to comment
Share on other sites

ok I M New to this and I do have a lot things to learn

I have a database named " onesixh3_bbs" and few tables and all the articles are stored in table   " carbon_topics"  as shown below

1454205562548615.png

 

 

 

and another table called " carbon_tags"  store all the tags  as shown below

in this table it has three tags which are " news, questions, help"

 

1454182383549301.png

 

NOW my question is how to create a rss feed  that only fetch articles  from table "carbon_tags" AND select from "news" only   I dont want articles from other name

 

 

here is what I m thinking join this two tables and select from carbon_tags.news   how to coding this ?

thank you so much really appreciate

Link to comment
Share on other sites

here is my three table data

=====================

--
-- Table structure for table `carbon_topics`
--
 
CREATE TABLE IF NOT EXISTS `carbon_topics` (
  `ID` int(11) NOT NULL AUTO_INCREMENT,
  `Topic` varchar(255) NOT NULL,
  `Tags` text,
  `UserID` int(10) unsigned NOT NULL DEFAULT '0',
  `UserName` varchar(50) NOT NULL,
  `LastName` varchar(50) DEFAULT NULL,
  `PostTime` int(10) unsigned NOT NULL,
  `LastTime` int(10) unsigned NOT NULL,
  `IsGood` tinyint(1) unsigned DEFAULT '0',
  `IsTop` tinyint(1) unsigned DEFAULT '0',
  `IsLocked` tinyint(1) unsigned DEFAULT '0',
  `IsDel` tinyint(1) unsigned DEFAULT '0',
  `IsVote` tinyint(1) unsigned DEFAULT '0',
  `Views` int(10) unsigned DEFAULT '0',
  `Replies` int(10) unsigned DEFAULT '0',
  `Favorites` int(10) unsigned DEFAULT '0',
  `RatingSum` int(10) unsigned NOT NULL DEFAULT '0',
  `TotalRatings` int(10) unsigned NOT NULL DEFAULT '0',
  `LastViewedTime` int(10) unsigned NOT NULL,
  `PostsTableName` int(10) unsigned DEFAULT NULL,
  `ThreadStyle` varchar(255) DEFAULT NULL,
  `Lists` longtext,
  `ListsTime` int(10) unsigned NOT NULL,
  `Log` longtext,
  PRIMARY KEY (`ID`),
  KEY `LastTime` (`LastTime`,`IsDel`),
  KEY `UserTopics` (`UserName`,`IsDel`,`LastTime`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
 
 
 
 
 
 
--
-- Table structure for table `carbon_posttags`
--
 
CREATE TABLE IF NOT EXISTS `carbon_posttags` (
  `TagID` int(11) DEFAULT '0',
  `TopicID` int(11) DEFAULT '0',
  `PostID` int(11) DEFAULT '0',
  KEY `TagsIndex` (`TagID`,`TopicID`),
  KEY `TopicID` (`TopicID`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
 
 
 
 
 
--
-- Table structure for table `carbon_tags`
--
 
CREATE TABLE IF NOT EXISTS `carbon_tags` (
  `ID` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `Name` varchar(255) NOT NULL,
  `Followers` int(10) unsigned DEFAULT '0',
  `Icon` tinyint(1) unsigned DEFAULT '0',
  `Description` mediumtext,
  `IsEnabled` tinyint(1) unsigned DEFAULT '1',
  `TotalPosts` int(10) unsigned DEFAULT '0',
  `MostRecentPostTime` int(10) unsigned NOT NULL,
  `DateCreated` int(10) unsigned NOT NULL,
  PRIMARY KEY (`ID`),
  KEY `TagName` (`Name`) USING HASH,
  KEY `TotalPosts` (`IsEnabled`,`TotalPosts`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
 
 
 
===================================================
 
I want select topics from table `carbon_topics` AND only certain tag for example "tag1"
 
here is what I do 
$sql = "SELECT  carbon_topics.Topic, carbon_topics.ID, carbon_topics.Tags
FROM carbon_topics
WHERE carbon_topics.Tags  = '​tag1' "; 
 
i think i failed 
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.