I have a table (url_log) with a column (referer) of urls. Some urls are unique and some are duplicates. Using PHP I want to display each different url (without repeating) and the number of times the url appears in the column.
This is what I came up with but it is definitely wrong:
echo '<table>';
$ref=$icdb->get_row("SELECT COUNT(referer) AS frequency, referer FROM url_log WHERE u = '".$dom."' GROUP BY referer ORDER BY frequency DESC");
foreach ($ref as $details) {
echo "<tr><td>".$details['referer']."</td><td>".$details['frequency']."</td></tr>";
}
echo '</table>';
Any tips?
GROUP BYandDISTINCT. Much faster and less code.