470,833 Members | 1,382 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,833 developers. It's quick & easy.

Duplicates

Hi

First sorry for my terreble english

I have mysql table like this:

id | name
---------------------
1 | Ivan
2 | John
3 | John

Now i wanna display it on web page like this

Ivan (1)
John (2)

Selecting duplicates, buth only showing number of duplicates..
How to do that?
tnx in advance
Dejan

Apr 13 '06 #1
6 1126
Dejan wrote:
Hi

First sorry for my terreble english

I have mysql table like this:

id | name
---------------------
1 | Ivan
2 | John
3 | John

Now i wanna display it on web page like this

Ivan (1)
John (2)

Selecting duplicates, buth only showing number of duplicates..


SELECT COUNT (id) GROUP BY name

Arjen
Apr 13 '06 #2
Arjen wrote:

SELECT COUNT (id) GROUP BY name


Ehmm .... SELECT name, COUNT (id) FROM table ORDER BY name
Apr 13 '06 #3
Arjen wrote:
Arjen wrote:

SELECT COUNT (id) GROUP BY name

Ehmm .... SELECT name, COUNT (id) FROM table ORDER BY name

SELECT name, COUNT(id) FROM table GROUP BY name

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Apr 13 '06 #4
How cann i display now name and count number in this code?

print "<table cellspacing=0 border=1 width=\"25%\" class=\"redovi\">\n";
print "<tr class=\"headline\"><td> Grad </td></tr>";
while ($qry = mysql_fetch_array($result)) {
print "<tr><td><a href=\"" . "prikaz_jednoga.php?id=$qry[id]\"
$qry[id]</a></td>"; print "</tr>\n";
}
print "</table>\n";
Jerry Stuckle <js*******@attglobal.net> wrote in message
news:P4******************************@comcast.com. .. Arjen wrote:
Arjen wrote:

SELECT COUNT (id) GROUP BY name

Ehmm .... SELECT name, COUNT (id) FROM table ORDER BY name

SELECT name, COUNT(id) FROM table GROUP BY name

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Apr 13 '06 #5
Jerry Stuckle wrote:
SELECT COUNT (id) GROUP BY name

Ehmm .... SELECT name, COUNT (id) FROM table ORDER BY name

SELECT name, COUNT(id) FROM table GROUP BY name


AAARCH !!

Well u know what I mean :-)

Arjen
Apr 13 '06 #6
Dejan wrote:
How cann i display now name and count number in this code?


Optianal: SELECT COUNT(id) AS mycounter

while $row=mysql_fetch_assoc($q)
{
echo "$row['name'] ($row['mycounter'])<br>\n";
}

Arjen

Apr 13 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by vsgdp | last post: by
14 posts views Thread by ak | last post: by
3 posts views Thread by ryan.paquette | last post: by
Thekid
3 posts views Thread by Thekid | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.