Reputation: 109
I have this
PHP CODE:
<?
require_once 'rss_fetch.inc';
$url = 'http://egyptian-planet.com/rss.php';
$rss = fetch_rss($url);
echo "Site: ", $rss->channel['title'], "<br>";
foreach ($rss->items as $item ) {
$title = $item[title];
$url = $item[link];
$pub = $item[pubdate];
$desc = $item[description];
$select_url = $mysqli->query("SELECT * FROM rssnews where url = '$url'");
$num_url = $select_url->num_rows;
if($num_url){
echo "";
}else{
$insert = $mysqli->query("INSERT INTO rssnews (id, title, url, date, desc1)
VALUE('', '$title', '$url', '$pub', '$desc')");
}
}
?>
But this code does not add news to database automatic I must refresh page.
How can I make this code add news to database automatic?
Upvotes: 1
Views: 289
Reputation: 219834
It only works when you refresh the page because that is the only way the code is told to execute. If you want this to run automatically you need to run a cron job.
Upvotes: 2