Code: Select all
<?php$referer=$_SERVER['HTTP_REFERER'];echo $referer;?>Moderator: General Moderators
Code: Select all
<?php$referer=$_SERVER['HTTP_REFERER'];echo $referer;?>if i put each url into a database table, with the time going , the table will become larger and larger.so, i want to let the database only save one day 's records。 when a new day comes, the old day's record will be deleted. is there a way to get this?MindOverBody wrote:On each visit, save referer url to database or a file, and when needed fetch that data from it.
i am sorry, i don't know how to set the timestamp colum and the initial value. could you write the line down.thank you!MindOverBody wrote:Yap, on database table, add column timestamp, and when inserting data into table, insert time stamp, and delete all where date('d', $timestamp_from_table) is not equal date('d', time()).
You will achieve that in your database refferers table will be only that day's inserts. Of course, you can play with this to achieve much more precise goal. Hope you understaned me
Code: Select all
function add_referer(){
//connect to your database here
// Add referer to database table with current time formated to insert only number of day in month
mysql_query("INSERT INTO db_table_name (referer, time) VALUES ('" . $_SERVER['HTTP_REFERER'] . "','" . date('d', time() ) . "')");
// now delete all table inserts which are not todays
mysql_query("DELETE FROM db_table_name WHERE time<>'" . date('d', time() ) . "' ");
}