Eddie01001 Posted January 30, 2016 Share Posted January 30, 2016 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? Quote Link to comment https://forums.phpfreaks.com/topic/300700-rssphp/ Share on other sites More sharing options...
Barand Posted January 30, 2016 Share Posted January 30, 2016 Add a WHERE clause to your query Quote Link to comment https://forums.phpfreaks.com/topic/300700-rssphp/#findComment-1530608 Share on other sites More sharing options...
Eddie01001 Posted January 30, 2016 Author Share Posted January 30, 2016 $sql = "SELECT * FROM carbon_topics WHERE carbon_catalog IN SELECT news is something like this? please help I am new and im learning please Quote Link to comment https://forums.phpfreaks.com/topic/300700-rssphp/#findComment-1530609 Share on other sites More sharing options...
Barand Posted January 30, 2016 Share Posted January 30, 2016 You have given no information about the table in the query, other than its name, so how do you expect us to help? Quote Link to comment https://forums.phpfreaks.com/topic/300700-rssphp/#findComment-1530610 Share on other sites More sharing options...
Eddie01001 Posted January 31, 2016 Author Share Posted January 31, 2016 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 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" 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 Quote Link to comment https://forums.phpfreaks.com/topic/300700-rssphp/#findComment-1530614 Share on other sites More sharing options...
Eddie01001 Posted January 31, 2016 Author Share Posted January 31, 2016 Quote Link to comment https://forums.phpfreaks.com/topic/300700-rssphp/#findComment-1530615 Share on other sites More sharing options...
Barand Posted January 31, 2016 Share Posted January 31, 2016 I see you have a column called "tags", which rings alarm bells for me, How are you storing the data in that column? Quote Link to comment https://forums.phpfreaks.com/topic/300700-rssphp/#findComment-1530632 Share on other sites More sharing options...
Eddie01001 Posted February 1, 2016 Author Share Posted February 1, 2016 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 Quote Link to comment https://forums.phpfreaks.com/topic/300700-rssphp/#findComment-1530653 Share on other sites More sharing options...
Eddie01001 Posted February 2, 2016 Author Share Posted February 2, 2016 i got thanks Quote Link to comment https://forums.phpfreaks.com/topic/300700-rssphp/#findComment-1530687 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.