For Programmers: Free Programming Magazines  


Home > Archive > PHP SQL > April 2006 > Duplicates









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Duplicates
Dejan

2006-04-13, 7:59 am

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



Arjen

2006-04-13, 7:59 am

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
Arjen

2006-04-13, 7:59 am

Arjen wrote:

>
> SELECT COUNT (id) GROUP BY name


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

2006-04-13, 7:59 am

Arjen wrote:
> Arjen wrote:
>
>
>
> 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.
jstucklex@attglobal.net
==================
Dejan

2006-04-13, 7:59 am

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 <jstucklex@attglobal.net> wrote in message
news:P4GdnYD8Gs3boqPZnZ2dnUVZ_tGdnZ2d@co
mcast.com...
> Arjen wrote:
>
>
> SELECT name, COUNT(id) FROM table GROUP BY name
>
> --
> ==================
> Remove the "x" from my email address
> Jerry Stuckle
> JDS Computer Training Corp.
> jstucklex@attglobal.net
> ==================



Arjen

2006-04-13, 7:59 am

Jerry Stuckle wrote:

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


AAARCH !!

Well u know what I mean :-)

Arjen
Arjen

2006-04-13, 7:59 am

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

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com