I have found questions related to removing duplicates and counting duplicates, but I haven't been able to add a duplicate count to MySQL rows, so I pose this question. Here's what I have so far:
$query = "SELECT * FROM Losers ORDER BY Date DESC";
$result = mysql_query($query) or die(mysql_error());
echo '<table>';
while($row = mysql_fetch_array($result)){
echo '<tr><td>' . $row['Name']. "</td><td>". date("l, M j, Y",strtotime($row['Date'])) . '</td></tr>';
}
echo '</table>';
mysql_close($con);
Now I want to include a count of the duplicates in Name for each row. So, it would read something like this:
Ben 2
Laura 3
Amy 1
Laura 3
Ben 2
Laura 3
I found a this query to group duplicates in Name and count them:
$newQuery = "SELECT Name, Date, COUNT(Name) FROM Losers GROUP BY Name";
But then it will output:
Ben 2
Laura 3
Amy 1
How do I incorporate both queries?