Page 1 of 1

Advance MySQL command how can i doe it ?

Posted: Tue Mar 28, 2006 4:00 am
by NeoNmaN
I whot to make a statestik system bot now i run to the troppel.

i hav relly manny insert in my MySQL database when i get the time and ip from on user fx. here

time: 1143533045
ip: 194.19.xxx.xxx

soe now im whot to get all unikke hist every day if you under stand. every day ist one ip adress only can be count whit bot next day the same ip adesse can be count one time more....

soe i need SQL Command if i can doe it whit SQL and not in my PHP code.

i hobe all understand og i hob i can be help here :)

Posted: Tue Mar 28, 2006 4:21 am
by s.dot
If you wish to rely on it like that,

store the date in a day format - a string that will change only once per day

like this

Code: Select all

$today = date("Ymd");    //    this will look like 20060328
$ip = however_you_determine_ips();

//    check if user has visited today
$result = mysql_query("SELECT count(*) FROM `table` WHERE `ip` = '$ip' AND `day` = '$today' LIMIT 1");
if(mysql_result($result,0) == 0){
    //    user has not visited yet, so update count
} else {
    //    user has visited
}

Posted: Tue Mar 28, 2006 4:31 am
by NeoNmaN
no ist not that i tnik one...

if you get 10000 post ind one table in you database and soe wil get all out when ist not linke more then 1 ip each one time each day soe if i hav a log from 14 days and 5000 post ist from the same ip adresse and soe you onlye will count 13 days becoures the user onlye hav look the website 13 times on 14days :) i hob you understand now :)

Posted: Tue Mar 28, 2006 8:57 am
by feyd
I have no idea what you just said. Maybe some examples would help.

Posted: Tue Mar 28, 2006 9:27 am
by jrd
i think he's looking for DISTINCT ip count in sql.

Code: Select all

select count(distinct ip) as IP ...