I have a page that has to display how many documents the user has given in for him to recieve commission
I tried count but it gives me totals, Im new to sql "count" and "group"
tabel has three fields:
id, user, date, refnum
1 - mike - 2012/01/01 - 12353
2 - Samy - 2012/01/01 - 12342
3 - mike - 2012/01/01 - 12325
4 - Jake - 2012/01/01 - 15315
5 - mike - 2012/01/02 - 15133
6 - mike - 2012/01/02 - 15512
6 - mike - 2012/01/02 - 12433
I want to show it like this
echo "".$user." has completed ".$records. " on ".$date;
my selet does not work, this is a mess.
$get_user_record_count = "SELECT user, COUNT(DISTINCT date) as 'date' FROM usertransactions GROUP BY user Where user='mike';"
$extracted = mysql_query($get_user_record_count) or die(mysql_error());
while ($rows = mysql_fetch_assoc($extracted))
{
$date = $rows['date'];
$user = $rows['user'];
//$records = $rows['count'];
echo "".$user." has completed ".$records. " on ".$date;
}
what i try and do is count the number of records per user per day.
and display in a list earliest date at the top
Mike has completed 2 documents on 2012/01/01
Mike has completed 3 documents on 2012/01/02
Hoe the peanut does one do this?