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."')"); HTML: I tried Insert and REPLACE, but they all insert new one behind the old. How to do a update? Thanks.
$qid = mysql_query("SELECT title FROM rss WHERE title='$title' AND date='$date' AND content='$content' AND link='$link' LIMIT 1"); if (mysql_num_rows($qid)==0) { mysql_query("INSERT INTO rss (link, title, date, content) VALUES ('".$link."', '".$title."', '".$date."', '".$content."')"); } PHP: only now inserts if not found
Thanks themullet, but mysql_num_rows(): supplied argument is not a valid MySQL result resource wrong in line: if (mysql_num_rows($qid)==0) { I replace $qid into $query, but it also alart wrong. I checked the mysql database, it also insert new rss items when I refresh the page.