RSS (Really Simple Syndication) is a very useful way to share content over internet. If you are running a website or blog RSS feeds can help you a lot by sharing your contents to readers. RSS feeds are based on XML markup. It holds some information about your post contents like post title, description, link, publish date etc.
In this post you will learn how we can create simple RSS feed with PHP and MySQL.
Creating MySQL Database Table
At first we need to create a database table that can hold our post contents.
CREATE TABLE `post` ( `id` int(6) NOT NULL AUTO_INCREMENT, `title` varchar(128) NOT NULL, `body` text NOT NULL, PRIMARY KEY (`id`) );
PHP Code
# configurations $db_host = 'localhost'; $db_user = 'root'; $db_pass = 'root'; $db_name = 'test'; $max_post_limit = 10; # set content type application/rss+xml header("Content-Type: application/rss+xml; charset=UTF-8"); # connect to mysql db mysql_connect($db_host, $db_user, $db_pass); # select mysql db mysql_select_db($db_name); # query in db table $query = mysql_query( 'SELECT * FROM post ORDER BY id DESC LIMIT ' . $max_post_limit ); ?> <?xml version="1.0" encoding="UTF-8"?> <rss xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"> <channel> <title>My RSS Feed</title> <description>w3bees RSS Feed</description> <link>http://www.w3bees.com</link> <language>en-us</language> <copyright>Copyright (C) 2013 w3bees.com</copyright> <?php while( $row = mysql_fetch_array($query) ): ?> <item> <title><?php echo $row['title']?></title> <description><?php echo $row['body']?></description> <link>http://mysite.com/post.php?id=<?php echo $row['id']?></link> </item> <?php endwhile?> </channel> </rss>
Nếu như còn gặp lại.
ReplyDeleteTa sẽ nói những gì
Lẽ nào nhìn vào mắt
dịch vụ kế toán trọn gói quận 3
dịch vụ kế toán trọn gói quận 2
dịch vụ kế toán thuế trọn gói tại tp hcm
Trước đây thất thì cảm thấy khủng khiếp lắm
Giờ còn thất nhiều hơn mà sao vẫn thấy vui vẻ thế
Hii I read your blog and found that your blog is full of informative content. So keep posting thanks for share this article.your article is very amazing.i like your article. thanks you ones again.
DeleteUNIRAJ BA 3RD YEAR RESULT 2020
UNIRAJ BSC 1ST YEAR RESULT 2020
RANCHI UNIVERSITY RESULT 2020
ALLAHABAD UNIVERSITY BA PART 3 RESULT
BA FINAL YEAR RESULT 2020
UU UNIVERSITY BA FINAL YEAR RESULT 2020
BSC RESULT 2020 (PART 1ST,2ND,3RD)
Hii I read your blog and found that your blog is full of informative content. So keep posting thanks for share this article.your article is very amazing.i like your article. thanks you ones again.
DeleteUNIRAJ BA 3RD YEAR RESULT 2020
UNIRAJ BSC 1ST YEAR RESULT 2020
RANCHI UNIVERSITY RESULT 2020
ALLAHABAD UNIVERSITY BA PART 3 RESULT
BA FINAL YEAR RESULT 2020
UU UNIVERSITY BA FINAL YEAR RESULT 2020
BSC RESULT 2020 (PART 1ST,2ND,3RD)
I have read your blog its very attractive and impressive. I like it your blog.
ReplyDeletePHP Training in chennai | PHP Training Course
PHP Training in chennai | Online PHP Course
Buông ra! – Hân cố giằng tay ra khỏi Bảo.
ReplyDelete– Nhìn thấy tôi tại sao lại chạy? – Bảo hỏi, bàn tay siết chặt hơn lấy cổ tay Hân. Tiếng anh cho người đi làm
Tiếng anh cấp tốc
Luyện thi toeic tại hà nội
Tiếng anh cho người lớn tuổi
Tiếng anh cho người mới bắt đầu
Học tiếng anh tại hà nội
dạy tiếng anh cho doanh nghiệp
– Mặc kệ tôi! – Hân vẫn cố giằng ra, sức mạnh của Bảo khiến Hân cảm giác như cổ tay mình bị vỡ vụn, vô thức, cô nhăn mặt. – Đau…
The info Shared is very much useful Thanks for sharing it
ReplyDeleteHadoop Training in Chennai
hi welcome to this blog. really you have post an informative blog. it will be really helpful to many peoples. thank you for sharing this blog.
ReplyDeletepython training in chennai
really you have been shared very informative blog. it will be really helpful to many peoples. so keep on sharing such kind of an interesting blog.
ReplyDeletehadoop training in chennai
SSVS Sansthan Recruitment 2017
ReplyDeleteSSVS Sansthan Recruitment
SSVS Sansthan Vacancy
SSVS Sansthan Job
IBPS PO Recruitment 2018
ReplyDeleteUP Police Recrutiemnt 2018
SSC GD Constable Recrutiment
UPSC IFS Recruitment 2018
SSC CPO Recruitment 2018
MP Anganwadi Recruitment 2018
RRB Chandigarh Recruitment 2018
ReplyDeleteRRB Bilaspur Recruitment 2018
RRB Mucaffarpur Recruitment 2018
RRB Siliguri Recruitment 2018
RRB Patna Recruitment 2018
RRB Ranchi Recruitment 2018
RRB Secunderabad Recruitment 2018
It's a great way to share content on the Internet!
ReplyDeletebasketball legends unblocked
Nice blog information thanks for sharing .I am really impressed with your writing abilities
ReplyDeleteคาสิโนออนไลน์ที่น่าเชื่อถือและมีความเป็นมืออาชีพที่สุดในตอนนี้
โปรโมชั่นGclub ของทางทีมงานตอนนี้แจกฟรีโบนัส 50%
เพียงแค่คุณสมัคร สล็อตออนไลน์ กับทางทีมงานของเราเพียงเท่านั้น
ร่วมมาเป็นส่วนหนึ่งกับเว็บไซต์คาสิโนออนไลน์ของเราได้เลยค่ะ
สมัครสล็อตออนไลน์ >>> Goldenslot
สนใจร่วมสนุกกับ คาสิโนออนไลน์ คลิ๊กได้เลย
มีทั้งคาสิโนออนไลน์ หวยออนไลน์ ฟุตบอลออนไลน์ สล็อตออนไลน์ และอื่นๆอีกมากมาย
Thank you for making me aware of this news.
ReplyDeleteหางานราชการ
You are very good at that.
ReplyDeleteงานราชการ
يسبب النمل الأبيض خسائر كبيرة فى الحبوب التى يتغذى عليها الإنسان، ويهاجم التمور، والذرة والمحاصيل التي تنثر على الأرض بغرض التجفيف تحت أشعة الشمس أو بحرارة الهواء.
ReplyDeleteشركة مكافحة النمل الابيض بحائل
شركة مكافحة النمل الابيض بالاحساء
شركة مكافحة النمل الابيض بالقطيف
شركة مكافحة النمل الابيض بالخرج
ReplyDeleteالرائد افضل شركات تنظيف خزانات المياه يسعدنا ان نقدم لكم افضل خدمات
شركة غسيل خزانات بالمدينة المنورة تنظيف خزانات بالمدينة المنورة
افضل شركة تنظيف منازل بالمدينة المنورة شركة تنظيف بيوت بالمدينة المنورة
It's very useful blog post with inforamtive and insightful content and i had good experience with this information. We, at the CRS info solutions ,help candidates in acquiring certificates, master interview questions, and prepare brilliant resumes.Find top Salesforce admin interview questions in 2020.
ReplyDeleteThese Salesforce developer interview questions are highly helpful in 2020. You can read these Salesforce lightning interview questions and Salesforce integration interview questions which are prepared by industry experts.
IEEE Final Year Project centers make amazing deep learning final year projects ideas for final year students Final Year Projects for CSE to training and develop their deep learning experience and talents.
ReplyDeleteIEEE Final Year projects Project Centers in India are consistently sought after. Final Year Students Projects take a shot at them to improve their aptitudes, while specialists like the enjoyment in interfering with innovation.
corporate training in chennai corporate training in chennai
corporate training companies in india corporate training companies in india
corporate training companies in chennai corporate training companies in chennai
I have read your blog its very attractive and impressive. I like it your blog. Digital Marketing Company in Chennai