Advance MySQL command how can i doe it ?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
NeoNmaN
Forum Newbie
Posts: 21
Joined: Mon Mar 27, 2006 4:08 am
Location: Denmark
Contact:

Advance MySQL command how can i doe it ?

Post 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 :)
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post 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
}
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
NeoNmaN
Forum Newbie
Posts: 21
Joined: Mon Mar 27, 2006 4:08 am
Location: Denmark
Contact:

Post 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 :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

I have no idea what you just said. Maybe some examples would help.
jrd
Forum Commoner
Posts: 53
Joined: Tue Mar 14, 2006 1:30 am

Post by jrd »

i think he's looking for DISTINCT ip count in sql.

Code: Select all

select count(distinct ip) as IP ...
Post Reply