Forum Moderators: coopster
I have this query:
$query = $DB->query( "select id, author, quote, date from quotes ORDER BY `author` ASC");
while( $row = $DB->fetch_row($query) ) {
$id = $row['id'];
$author = $row['author'];
$autors.="<tr><td> - <a href=\"?pg=quote&act=autori&name=$author\">$author</a></td></tr>";
}
And I want to show a list with names of quote authors.
The problem is:
If a have 2 or more quotes one of authors the name of author appear 2 or more time (how quotes have with that name).
Es.
- William Shakespeare
- William Shakespeare
- William Hazlit
- William Congreve
- William Blake
- William Blake
- Wilhelm Burch
I want to show one time only each name. How can solve this?
a query like this should give you a list of authors and a count of quotes for each:
SELECT author, COUNT(author) AS quote_count FROM quotes GROUP BY author ORDER BY author
otherwise you could use logic in your while loop to skip duplicates...