brown2005 Posted March 9, 2006 Share Posted March 9, 2006 hi,i have if ($_GET['id']) {$sq1 = "SELECT * FROM ads_hits WHERE hits = '".$_GET['id']." ".$_SERVER['REMOTE_ADDR']."'";$r1 = mysql_query($sq1) or die(mysql_error());$sql2 ="UPDATE ads_hits SET hits_count= hits_count +1 WHERE hits='".$_GET['id']." ".$_SERVER['REMOTE_ADDR']."' ";$updated=true;mysql_query($sql2);echo FINISHED;exit();}and this adds one to the count, but now i want to be able to say if the ip and id have not had a hit then it will add the ip and id to the database and if it has 1 hit or more then it runs the query above... Quote Link to comment Share on other sites More sharing options...
obsidian Posted March 9, 2006 Share Posted March 9, 2006 first, you just need to see if the IP is existing in the DB already. if it's not, run the code you've already got going:[code]$ip = $_SERVER['REMOTE_ADDR'];$sql = mysql_query("SELECT COUNT(*) AS count FROM tableName WHERE ip = '$ip'");if (mysql_result($sql, 0, 'count') > 0) // they've already been hereelse { // run your increment code here}[/code]hope this helps! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.