l3rodey Posted March 3, 2014 Share Posted March 3, 2014 Hi, So I am building a keyword tracking tool for a friend, All in all it's pretty much done, But for the actual tracker in this case is www.example.com/tracker?keyword=This-is-a-keyword This has a $_GET which pulls the keyword, I also get the geolocation, ip, OS and browser. When my friend used adwords each keyword will link to tracker?keyword= then the keyword and yeah... pretty indepth backend to control it all. What I am wanting to do is run a sql lookup on the IP address each time someone visits it does a lookup in the views and sees if that user has had that keyword under that ip in the past 3 days, if yes then just adds another page view as I monitor how many views each user has done. If they have not seen that keyword in the last 3 days then it inserts it. The problem I am having is I don't know how to do they query this is what I have: $getVisitor = mysql_query("SELECT * FROM keywordViews WHERE ipaddress='$ipaddress' AND DATE(visitdate) BETWEEN DATE(NOW()) AND DATE(adddate(NOW(), INTERVAL 3-DAYOFWEEK(NOW()) DAY))", $tracker); while($row = mysql_fetch_array($getVisitor)) { $viewID = $row['viewID']; } I am not a pro, I get past guessing and trial and error, But I had this code writen for me months ago for another project so I tried to use it and change it but it fails... At this stage all I am trying to do is echo out the viewID for my IP address to see if it's outputting correctly and expand. Can someone please help me fix my query to check ipaddress is entered in keywordViews in the last 3 days if yes then do this if not then do something else? Thanks. Quote Link to comment Share on other sites More sharing options...
paddy_fields Posted March 4, 2014 Share Posted March 4, 2014 (edited) Assuming your SQL query is working correctly... EDIT: Just read the part where you said it fails $num_rows = mysql_num_rows($getVisitor); if($num_rows==0){ // there were no matches, so do this } else { // there were matches, so do this } Edited March 4, 2014 by paddyfields 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.