Skip to main content

Generate RSS Feed with PHP & MySQL

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.

  `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

# query in db table
$query = mysql_query(
  FROM post
  LIMIT ' . $max_post_limit

<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:media="" xmlns:itunes="" xmlns:feedburner="" version="2.0">


    <title>My RSS Feed</title>
    <description>w3bees RSS Feed</description>
    <copyright>Copyright (C) 2013</copyright>

  <?php while( $row = mysql_fetch_array($query) ): ?>

      <title><?php echo $row['title']?></title>
      <description><?php echo $row['body']?></description>
      <link><?php echo $row['id']?></link>

  <?php endwhile?>



  1. Nếu như còn gặp lại.
    Ta 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ế

  2. I have read your blog its very attractive and impressive. I like it your blog.

    PHP Training in chennai | PHP Training Course

    PHP Training in chennai | Online PHP Course

  3. Buông ra! – Hân cố giằng tay ra khỏi Bảo.
    – 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…

  4. The info Shared is very much useful Thanks for sharing it
    Hadoop Training in Chennai

  5. 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.
    python training in chennai

  6. 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.
    hadoop training in chennai

  7. It's a great way to share content on the Internet!
    basketball legends unblocked

  8. Nice blog information thanks for sharing .I am really impressed with your writing abilities

    โปรโมชั่นGclub ของทางทีมงานตอนนี้แจกฟรีโบนัส 50%
    เพียงแค่คุณสมัคร สล็อตออนไลน์ กับทางทีมงานของเราเพียงเท่านั้น
    สมัครสล็อตออนไลน์ >>> Goldenslot
    สนใจร่วมสนุกกับ คาสิโนออนไลน์ คลิ๊กได้เลย
    มีทั้งคาสิโนออนไลน์ หวยออนไลน์ ฟุตบอลออนไลน์ สล็อตออนไลน์ และอื่นๆอีกมากมาย

  9. يسبب النمل الأبيض خسائر كبيرة فى الحبوب التى يتغذى عليها الإنسان، ويهاجم التمور، والذرة والمحاصيل التي تنثر على الأرض بغرض التجفيف تحت أشعة الشمس أو بحرارة الهواء.

    شركة مكافحة النمل الابيض بحائل
    شركة مكافحة النمل الابيض بالاحساء

    شركة مكافحة النمل الابيض بالقطيف
    شركة مكافحة النمل الابيض بالخرج


  10. الرائد افضل شركات تنظيف خزانات المياه يسعدنا ان نقدم لكم افضل خدمات
    شركة غسيل خزانات بالمدينة المنورة تنظيف خزانات بالمدينة المنورة
    افضل شركة تنظيف منازل بالمدينة المنورة شركة تنظيف بيوت بالمدينة المنورة

  11. 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.
    These 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.


Post a Comment

Popular posts from this blog

Multiple File Upload with Progress Bar using PHP & jQuery

Some days age I have created a post that deals with How we can upload file with progress bar using php and jQuery . Some of my readers asked me how we can upload multiple files with progress bar. In this post I am going to show you how we can upload multiple files with progress bar. We can upload multiple files with progress bar exactly same way as I shown previous. But we need to do some modification with our file upload form and our php script to handle multiple files.

Force File Download with PHP

If you want to control or track your downloadable contents then a force file downloader script can give you more option. Especially if you want make images or other stemming contents like music file (mp3, wav, ogg), video files (flv, mp4, ogg, 3gpp), css, JavaScripts or even a php file downloadable then you must need to use a force file downloader script. In this post I am going to share a simple but useful force file downloader script.

Multiple File Upload with PHP

Sometimes we need to allow our users to upload multiple file upload. On my previous post I was shown the basic of simple file upload with PHP. Today I am going to show you how to allow users to upload multiple files. It is almost similar like simple file upload but we need to do some modification with html markup and php code . multiple attribute is needed to add on the html markup. Major web browsers like Firefox, Chrome, Safari and IE 9+ support this attribute. Now I am going to show you how to upload multiple file with PHP and basic HTML form.