arkismad;10910805 wrote:include("mainfunctions.php");
connect();
$date = date('Y-m-d H:i:s'); //YYYY-MM-DD HH:MM:SS
$raw = mysql_query("SELECT * FROM `globaldaily`") or die ( 'Error Finding Global Settings');
$global = mysql_fetch_assoc($raw) ;
if($global['date'] == $date){
echo "Date Allready Added";
}else{
mysql_query("INSERT into globaldaily (hits) values ('0')") or die ( 'Broken');
}
this is what i have, and its not working 🙁
probably because your query should be more like
"SELECT * FROM globaldaily ORDER BY date DESC LIMIT 1"
but, like Piranha said, that logic is a little .. un-good .., a better approach would be to add new row each visit and store more information, ie; ip addresses, browser type, time etc.
also after your second query, if you just want the hit counter to increase +1 every visit on todays row, you can do
"UPDATE globaldaily SET hits = hits +1 WHERE date='{$date}'"
..Another alternative, is to write a query that creates the rows for the next two years.. that way if 0 people visit the site one day, they'll be a record for 0 entries instead of a row not even existing for that day,