MySql: Select all entries with count...
Posted
by Scarface
on Stack Overflow
See other posts from Stack Overflow
or by Scarface
Published on 2010-03-31T19:27:47Z
Indexed on
2010/03/31
19:43 UTC
Read the original article
Hit count: 365
Hey guys quick question, I have a query that I want to count all entries it finds, and select all so when I use while($row=mysql_fetch_assoc($query)){
it will list all entries. The problem I am encountering is that while, all the entries are successfully counted and the right number is listed, only the latest entry is select and listed when I echo $row['title']. If I delete , COUNT(*) as total
then it selects all but I was wondering if it was possible to use count and select *. I was wondering if anyone knew what I am doing wrong?
SELECT *, COUNT(*) as total FROM new_messages WHERE username='$session->username
© Stack Overflow or respective owner