Forum Moderators: coopster

Message Too Old, No Replies

Mysql results

Mysql results

         

gonny

9:43 pm on Feb 8, 2008 (gmt 0)

10+ Year Member



Hi all,

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?

coopster

1:25 am on Feb 9, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Show the author's name only once, no matter what? What if the quote is different?

phranque

1:28 am on Feb 9, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



a query like this should give you a list of authors:
SELECT DISTINCT(author) FROM quotes ORDER BY author

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...

gonny

12:06 pm on Feb 10, 2008 (gmt 0)

10+ Year Member



thnx a lot guys