Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

youlichika

macrumors member
Original poster
Aug 27, 2010
35
0
I have ordered yahoo news rss, I use simplepie to separate the news items like title, content, url, date... and then insert them into database. I catch the source every 2 hours with cron. How to judge RSS source, if there has new then UPDATE into database?

I mean if the rss source has 10 items, 5 are old, 5 are new, I want just update the 5 items new and ignore the 5 old items. I do not want insert the repeart items.
And I want to get `echo` a list of the 5 new items.

This is my insert code.

Code:
mysql_select_db("rss",$db1);
mysql_query("INSERT INTO yahoonews (link, title, date, content, image, imagelink) VALUES ('".$link."', '".$title."', '".$date."', '".$content."', '".$image."', '".$imagelink."')");
 
I am sure there are multiple ways to approach this, but mine would be to store the timestamp of the most recent post in a table. Then when you grab the new posts later on, you can set up your code to ignore any posts with a timestamp that is the same or earlier than that.

If you don't know how to create MySQL tables or set up if/then statements, you will need to do some more studying! (or find someone to write it for you :D )

HTH,

~ Jeremy
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.