hey guys,
im trying to count the number of results from my database based on the week number.
The thing is there are multiple users with the week number, who have multiple reuslts.
ie
username1 - week 48
username2 - week 48
username2 - week 48
username2 - week 48
username3 - week 48
What im trying to do is write a scipt that will output the following result:
username1 - 1 results
username2 - 3 results
username3- 1 result
any idea how i do this?
i been trying:
$db = mysql_connect($db_host,$db_user,$db_pass);
mysql_select_db ($db_name) or die ("Cannot connect to database");
$result = mysql_query("SELECT user_id, count( 'week' ) FROM failed WHERE week = '$week_now' GROUP BY user_id");
$countdata = mysql_num_rows($result);
echo $countdata;
while($r=mysql_fetch_array($result))
{
$user_id=$r["user_id"];
$week=$r["week"];
echo "$device_id, $week<br>";
David