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 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.
 
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
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.