In your table of links, have a column called 'clicked' that tracks the last time it was clicked. Store a unix timestamp as a 10 character varchar.
When you query the database to find the links, filter out the ones that are older than 24 hours, and sort them by last click date. The query should look like this:
$result = mysql_query("SELECT * FROM links WHERE links_clicked < " . strtotime("now - 24 hours") . " ORDER BY links_clicked LIMIT 0, 10");
That will give you 10 links that have been clicked the longest time in the past, and are at least 24 hours old.
Then when they click the link, don't take it to the link's page immediately. From the query above, print the links like this:
while( $row = mysql_fetch_array($result) )
{
echo("<a href='redirect.php?id=$row[link_id]' target='_blank'>$row[links_title]</a><br>");
}
This way the links go to 'redirect.php'. Redirect will do 2 things. First it updates the link with the current time, and then it redirects to the page they wanted. Something like this:
if( !empty($_GET['id']) && is_numeric($_GET['id']) )
{
mysql_query("UPDATE links SET links_time = " . time() . " WHERE links_id = " . $_GET['id']);
$result = mysql_query("SELECT links_url FROM links WHERE links_id = " . $_GET['id']);
$row = mysql_fetch_row($result);
header("Location:" . $row[0]);
}
or die("you have accessed this page incorrectly");
You can read more about using unix timestamps here:
http://www.webhead.cc/main.php?inv=59