I have been searching a lot in the past few days on listing fb likes in database. I have got help from here too. Now i know how to get likes data from fb, read the results and update it in database.
When I get likes of 100+ fb pages in a loop and if my end users are more, it puts a load on the database and the code runs very low. So I made two links. first link (update.php) updates the data in database and second (index.php) shows the figures to user which runs fast. Now I want to add an auto update feature every one hour.
I know the logic but dont know how to convert it in syntax. I thought of making a 'update' table with only one field which would be of datatime type. When the end user visits the link, it will first read the datetime value from the 'update' table. If the difference between current time and last updated time from the table is more than one hour then run a function (i already wrote one) else run the remaining part of the code without running the function.
Please advice if this logic is correct and help me with the syntax.
Editing below after being put on hold
I have a code (in update.php) that reads 'Likes' from fb pages and puts it in my database fbdb in table fbtable under the field fblikes. This is working. I have another code (in index.php) that reads data from fbtable and shows the fblikes field values in front end. The end user will always see old Likes... that is, the data available in fbtable. The updated likes will be shown to user only if i run the update.php file. I am not merging both the files because if I have 100+ pages, the page loads very slow and that is why I wanted a function that will check the last updated datetime in 'update' table and if the difference of current time and last updated time is more than 1 hour then the update.php should run to ensure that the data is updated every 1 hour.
<?php
include "conn.php";
?>
<html>
<head>
.
.
</head>
<body>
read datetime from 'update' table
if current time - last updated time > 1 hour
run the function
else
do below task
.
.
show data from database to end user
.
.
</body>
</html>
Thank you