scoutt
Thu 23rd May '02, 5:36pm
ok let me try to explain what I got. I'm trying to do a stats page from a access.log file. I have the ip in a table and was wondering how I can sort them in a way to where when they get listed on the page that they are in order of most visits but don't have any duplicates.
I tried to do a "select DISTINCT ip form stats" but that only gives me 1 of each.
so I thought of doing this
$find = mysql_query("select DISTINCT ip from Stats order by ip");
while($row = mysql_fetch_array($find)){
$find2 = ("select count(ip) from Stats where ip = '".$row["ip"]."'");
$vis = mysql_query($find2);
while ($row2 = mysql_fetch_array($vis)){
$page = $row2["count(ip)"];
}
}
but that will only give the total for that ip and it doesn't nothing to sort them. this works but like UI said it doesn't put them in any order. is there a way to have 1 sql statement so I can get the order I want but only get the distinct so I don't have duplicates.
thanks guys
I tried to do a "select DISTINCT ip form stats" but that only gives me 1 of each.
so I thought of doing this
$find = mysql_query("select DISTINCT ip from Stats order by ip");
while($row = mysql_fetch_array($find)){
$find2 = ("select count(ip) from Stats where ip = '".$row["ip"]."'");
$vis = mysql_query($find2);
while ($row2 = mysql_fetch_array($vis)){
$page = $row2["count(ip)"];
}
}
but that will only give the total for that ip and it doesn't nothing to sort them. this works but like UI said it doesn't put them in any order. is there a way to have 1 sql statement so I can get the order I want but only get the distinct so I don't have duplicates.
thanks guys