How to judge RSS source, if there has new then UPDATE into database?

Discussion in 'Web Design and Development' started by youlichika, Jan 13, 2011.

  1. youlichika macrumors member

    Joined:
    Aug 27, 2010
    #1
    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."')");
     
  2. designguy79 macrumors 6502

    Joined:
    Sep 24, 2009
    Location:
    Michigan
    #2
    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
     

Share This Page