How To Create A Reliable RSS Feed
By: Ted Peterson
You probably already know what RSS is - it is a file format for syndicating news and the content of sites, in a very flexible manner. What you probably don't know is that creating a correct RSS feed is in many cases a very difficult task for webmasters. I am not talking about sites that supply just a few news a day, I am talking about sites that supply tens of news a day.
Let's take for example a shareware site. For the site to become popular, it has to be always up to date and to contain all the latest releases. So, the webmasters have to search for the new titles and add them to their databases. Many of them offer their visitors the possibility to stay informed about the latest releases using RSS feeds, which contain their names, links and short descriptions of the new releases. Visitors interested in this kind of information subscribe to the RSS feeds, using web-based or desktop aggregators, like Bloglines or SharpReader. All the aggregators query the RSS feeds every couple of hours, which is sufficient for many of the feeds, but not for all of them. It is a common practice that the feeds supply only the last 20 items, but what if, between two queries from the aggregators, appear, let's say, 43 items? Then, 23 of them wouldn't appear to the subscribers. Probably you've never thought about this, but I can assure you this situation really occurs, and you have to solve it, for you and your visitors' interest.
I will now show you a solution to this problem, implemented in PHP, one of the most used scripting languages on websites that are led by large databases. The main idea is that we will compare the date of the first and the 20th item, and if they are equal, we will run an extra query, to also add the other items that appeared in the database in the same day.
Lets suppose that the table from which we want to take the last items is named "products" and has 4 fields: "p_name" (product name), "p_added" (date when the product was added), "p_link" (product link) and "p_description" (product description). We have 2 functions, one that adds an item to the feed, and one that adds the standard elements of a RSS file, and then queries the database for the items added to the table on the current day.
function additem($t, $l, $d)
{
$r= "\n";
$r.="$t\n";
$r.="$d\n";
$r.="$l\n";
$r.="\n";
return $r;
}
function create_rss()
{
$r ="\n";
$r.="\n";
$r.=" \n";
$r.=" Core Download - Latest 20 releases\n";
$r.=" http://www.coredownload.com/\n";
$r.=" The essential shareware and freeware downloads!\n";
$r.=" en-us\n";
$q1="SELECT * FROM `products` WHERE 1 ORDER by p_added DESC LIMIT 0,20";
$result1 = mysql_query($q1);
$i=0;
while ($row = mysql_fetch_array($result1))
{
$i++;
if ($i==1) { $data1=$row[p_added]; }
$r .=additem($row[p_name], $row[p_link], $row[p_description]);
$data2=$row[p_added];
}
if ($data1==$data2)
{
$q1="SELECT * FROM `products` WHERE `p_added`='$data2' LIMIT 20,1000";
$result1 = mysql_query($q1);
while ($row = mysql_fetch_array($result1))
{
$r .=additem($row[p_name], $row[p_link], $row[p_description]);
}
}
$r.=" \n";
$r.=" \n";
echo $r;
}
As you will see if you use this solution on your website, your feed's subscribers will find out about all your items (products, articles, or anything else), no matter how many they are. You can see this solution implemented on CoreDownload.com , a brand new shareware and freeware directory, that offers its visitors 3 RSS feeds: one for all the products, one for shareware and one for freeware.
|
About The Author
Ted Peterson writes for CoreDownload. Visit www.coredownload.com to see this RSS feed system implemented.
|
This article was posted on November 02, 2005
Shut Up, Put Up, and Get Some Quiet Back
When firestorms raged across Southern California and land lines were down, having a cell phone to call my family was a blessing. When I could sit in my ocean front garden and use both hands while talking to my Mother in Florida, I adored my cell phone. After getting lost in a jumble of streets, a cellular call helped me find my client. It's become my everywhere companion and yet, I am aware t. . .
Return to Index
UK
Financial Services
Sub-categories: Accounting
| Banks
| Building
Societies | Corporate
Finance | Credit
Services | Currency
Services | Debt
Collection | Directories
| Factoring
| Financial
Consultants | Fund
Management | Independent
Financial Advisors | Information
Services | Insurance
| Leasing
| Merchant
Services | Offshore
Services | Organisations
| Personal
Finance | Publications
| Regulation
| Socially
Responsible Investment | Stockbrokers
| Taxation
Article Index: 1
- 2 - 3
- 4 - 5
- 6 - 7
- 8
World
Financial Services
Sub-categories: Associations
| Automobile
Buying and Financing | Banking
Services | By
Region | Cash
Flow | College
Financing | Commercial
Lending | Computer
Financing | Cooperatives
| Credit
and Collection | Directories
| Education
and Training | Employment
| Field
Service Companies | Financial
Consultants | Financial
Planning | Freelancer-Contractor
Services | Holding
Companies | Information
Services | Insurance
| Investment
Banks | Investment
Services | Leasing
Services | Loans
| Marketing
and Advertising | Medical
Billing | Merchant
Services | Mortgages
| News
and Media | Offshore
Services | Payroll
Services | Surety
Bonds | US
Government Financial Sites | Venture
Capital | World
War II Dormant Accounts
Get "IN TO" Vicky's
"rr-tit-calls" (Vicky's a Yorkshire Lass)
Latest News & Previews
So
Today – The Rising Fame of Hilary Duff
It’s undeniable - if you had never seen Hilary Duff before
in your life her beautiful face would instantly sweep you up. With pearlescent
eyes that never quite seem the same colour in any two pictures, and a face
that screams both girl next door and sexpot, it is obvious to see why she has
captivated the music and silver screen industries.At a mere eighteen years of
age Hilary has already been in the spotlight for eight years. Her career
began, as so many do in Tinsel Town, with a small un-credited part in the Emmy
nominated TV movie, “True Women”. It makes sense that Hilary’s first
debut o. . .
Take
Care Of Your Furniture
Your furniture is a huge investment! So is your car and your
house. So if you put a lot of work into your car or your house, like getting
oil changes or putting in new floors, why would you not do the same with your
furniture? Your furniture gets used a lot and you can help maintain its value
by following these ideas.Keep your furniture clean. If it's cloth furniture,
you should vacuum it regularly. If it is leather furniture, you should wipe it
down and use leather treatment regularly. And if it's made of wood, you need
to keep it polished. But what if it has already taken a beating? What . . .
Taking
Care of your Soul Mate: Useful Piano Care Tips
Your piano is your soul mate. Once you start playing it, you
two are hopelessly entwined, enjoying a world of your own, mindless of what
goes on outside your world. It is therefore absolutely important that you take
care of your piano properly.Taking care of your piano does not only entail
having it tuned up every two to five years. It would also appreciate a daily
maintenance from the owner himself. What good would it do to a piano if it
would just be left at one corner of the house, untouched for sometime?
Absolutely nothing, and it would just gather dust and rust. One of the best
ways to. . .
|