How to update date into mysql from external RSS subion?

Discussion in 'Web Design and Development' started by youlichika, Oct 26, 2010.

  1. youlichika macrumors member

    Aug 27, 2010
    I want to subscribe a external RSS feed, it with 10 items. and I want to store it into mysql database. When I refresh the page, the database can uptade, the new 10 rss items will replace the older 10.

    require_once ('conn.php');mysql_select_db("my_db", $db);mysql_query("REPLACE INTO rss (link, title, date, content) VALUES ('".$link."', '".$title."', '".$date."', '".$content."')");
    I tried Insert and REPLACE, but they all insert new one behind the old.
    How to do a update? Thanks.
  2. SrWebDeveloper macrumors 68000


    Dec 7, 2007
    Alexandria, VA, USA
    Insert inserts new stuff.
    Replace is a MySQL method used to replace data within a string.

    You need to use the update method, i.e. this syntax:

    update table set field1=data1, field2=data2 where id=whatever

    This method assumes there is an ID of some sort used to update the proper feed if you have more than one, and that the number of channel items in the feed (you said 10) is always the same.

    But you get the idea, the update is what's important here.


Share This Page