Hello. I'm using the code below to run a query that generates a links page. I write the results out to a file so I can use crontab to run the query only every 24 hours, rather than every time a surfer hits the page. The timing works great, but I have one last detail I’m struggling with.
My question: How do I rotate this list so everyone gets an equal shot at being at the top? I suspect I should use the ID field as a marker of some sort, but I'm not sure how. I would like the query to take the current ID, count down 10 sites, place the new marker there and list that site as #1. 24 hours later take that site, move down 10 more etc.
$list = fopen("/home/aspen2/public_html/include/list.php", "w");
fwrite($list, "<TABLE BORDER=1><TR><TH>SITE TITLE</TH><TH>SITE DESCRIPTION</TH><TH>IN</TH><TH>OUT</TH><TH>DATE</TH></TR>");
while ($row = mysql_fetch_array($sql_result)) {
fwrite($list, "<TR><TD><A HREF=\"$row[SITE_URL]\">$row[SITE_TITLE]</A></TD><TD>$row[SITE_DESC]</TD><TD>$row[SITE_IN]</TD><TD>$row[SITE_OUT]</TD><TD>$row[SITE_TIMESTAMP]</TD></TR>");
}
fwrite($list, "</TABLE>");
fclose($list);
If anyone has any ideas about the best way to rotate my list, please share them.
Thanks!
Rich S