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
Share on other sites

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 by paddyfields
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.