Jump to content

Query help (date)


l3rodey

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/286685-query-help-date/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.