Okay well i am making logs. Where it log's the person's ip who logs in. Well everytime they click Main.php it log's their ip. so when you go to view the logs it shows alot of that 1 user with the same ip..
What i want it to do is when you view the logs i want it to check and see if the user has the same ip. if not it will show both ip's.
Like for example:
whitey (username)
127.126.0.0 (IP)
and it has multiple of those i just want it to display it once..
but if it has a different ip display both of those..
like for example:
whitey
127.126.0.0
127.121.1.0
if you could just help me start this i can finish it. Thanks :)
Displaying 1 of multiple
Started by Whitey, Jun 27 2008 07:29 PM
5 replies to this topic
#1
Posted 27 June 2008 - 07:29 PM
|
|
|
#2
Posted 27 June 2008 - 08:22 PM
By storing your logs in a delimited format, you can dump the contents into an array. From there, its simple.
#3
Posted 29 June 2008 - 10:21 AM
guessing its MySQL...
Just use
then under that
its actually exactly what I had a problem with... and that code fixed it, if you want to see my example, go to V.B. login as the sample account or make an account, launch the browser, then click history.
What it does is looks through the `history` table, which has "id, date, url, member" as the format, then SELECT DISTINCT date WHERE username=username
that will echo the date, then SELECT URL WHERE date=date and username=username..
all from one table, yet groups them by date, just like you want to group them by username, correct?
Just use
Quote
SELECT DISTINCT `username` FROM ....
Quote
SELECT `IP` FROM table WHERE `username`='$username'
its actually exactly what I had a problem with... and that code fixed it, if you want to see my example, go to V.B. login as the sample account or make an account, launch the browser, then click history.
What it does is looks through the `history` table, which has "id, date, url, member" as the format, then SELECT DISTINCT date WHERE username=username
that will echo the date, then SELECT URL WHERE date=date and username=username..
all from one table, yet groups them by date, just like you want to group them by username, correct?
Edited by phpforfun, 29 June 2008 - 10:24 AM.
Checkout my new forum! http://adminreference.com/
#4
Posted 29 June 2008 - 01:46 PM
yea my friend gave this as well.. Thanks man it works great!
#5
Posted 29 June 2008 - 05:54 PM
no problem sir :) You should thank Jordan and John for showing me, lol
Checkout my new forum! http://adminreference.com/
#6
Guest_Jordan_*
Posted 30 June 2008 - 03:18 AM
Guest_Jordan_*
The SQL above will work fine, you can also do what John suggested and use an array. This function: array_unique will remove duplicates.
It depends on where you want to do the removal of duplicates, in the DB or in PHP. Typically, using PHP is faster but in this case I'm not sure if you will see much difference. Perhaps I should do a benchmark on it and blog about it? :)
Quote
Takes an input array and returns a new array without duplicate values.
Note that keys are preserved. array_unique() sorts the values treated as string at first, then will keep the first key encountered for every value, and ignore all following keys. It does not mean that the key of the first related value from the unsorted array will be kept.
Note that keys are preserved. array_unique() sorts the values treated as string at first, then will keep the first key encountered for every value, and ignore all following keys. It does not mean that the key of the first related value from the unsorted array will be kept.
It depends on where you want to do the removal of duplicates, in the DB or in PHP. Typically, using PHP is faster but in this case I'm not sure if you will see much difference. Perhaps I should do a benchmark on it and blog about it? :)


Sign In
Create Account


Back to top









