Jump to content

Recommended Posts

Getting the same count everytime

 


$visitquery = mysql_query("SELECT COUNT(*) FROM visitors WHERE ownerkey = '$uuid' & region = '$selected' AND `date` < DATE_ADD(CURDATE(), INTERVAL +7 DAY)", $connect);
$row9 = mysql_fetch_array($visitquery); 
$visitoramount = $row9[0];
 print "[$visitoramount] visits in the last 7 days!";

If $selected = "Blah" it gives the count as " 8"

if $selected = "Dumb" it gives the count as "8" ... Al though there is no "Dumb" in the db.

 

Sorry if my explaining is off. Just dont know another way to explain it easier.

Link to comment
https://forums.phpfreaks.com/topic/179305-solved-count/
Share on other sites

I don't think you can use the '&' in a WHERE clause, change that to AND:

$visitquery = mysql_query("SELECT COUNT(*) FROM visitors WHERE ownerkey = '$uuid' AND region = '$selected' AND `date` < DATE_ADD(CURDATE(), INTERVAL +7 DAY)", $connect);

 

By the way, shouldn't that be "date > CURDATE - 7" ?  I mean if you are looking for the number of visits in the past seven days.  Your query specifies all dates less than NEXT WEEK; that would probably be all of them.

Link to comment
https://forums.phpfreaks.com/topic/179305-solved-count/#findComment-946038
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.