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

    Joined:
    Aug 27, 2010
    #1
    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.

    HTML:
    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

    SrWebDeveloper

    Joined:
    Dec 7, 2007
    Location:
    Alexandria, VA, USA
    #2
    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:

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

    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.

    -jim
     

Share This Page