apologize if there is already answer for that, but as a newbie to I’m not able to recognize one.
I have a trouble with outputing data from MySQL.
Imagine a table “visits” in MySQL:
1. name------surname------date------visitTime
2. John White 20111017 13:00
3. John White 20111017 17:00
4. John White 20111017 19:00
5. John White 20111018 07:00
6. Jack Black 20111017 09:00
7. Jack Black 20111018 16:00
I would like to have number of visits sumarized by date and printed out on the php page like this
1. name surname 20111017 20111018 ----> other days
2. John White 3 1
3. Jack Black 1 1
the query I’m using so far is
$query = "select name,surname,count(*) as visitCount
from visits group by name,surname,date";
thanks a lot
I don’t think you want to do it like that. Like KA_lin said this could get very very ugly as you get more and more different visit days.
A cleaner solution would be to group the data with this query.
“select name, surname, date, count(date)
from visits
group by name, surname, date;“
name surname date visitCount
Jack Black 20111017 1
Jack Black 20111018 1
John White 20111017 3
John White 20111018 1