Forum Moderators: coopster
id ¦¦ file_id ¦¦ time ¦¦ ip_address ¦¦ referrer
The information is added great and I love it, but I want to display it a certain way.
How I want is it to display the top five referrers and top five ip addresses for a certain $file_id. I think it would be a certain kind of for each inside of a while statement? Please help me get to the next level in php programming. Thx
;)
SELECT DISTINCT field, COUNT(*) AS count FROM table GROUP BY field ORDER BY count DESC LIMIT 5;
replace all bolded items with the actual names of cols, fields, tables
distinct
retrieve each unique output record just once by adding the keyword DISTINCT
count
try something like
select count(colname) as count from tablename
that will show you, but it essentially does what you would think counts the fields that match the query and returns an integer
group by [mysql.com]
order by colname == "sort by" column name
desc == descending
asc == ascending
that help? try changing to the cols, tables etc in your particular db and then see if you can get it to work
and you're not nagging