If any body could just give me a hint on this. I have a table called 'gents_names' filled with many names. What I need to do is count how many times the names appear in the table. Example: Name count fred 10 chris 5 jack 16 any help? please
Select name, count(*) from gents_names group by name that should work, but "name" might be a reserved word, depending on what SQL engine you're using.
thanks, its a bit more complexed than that, I used names etc to explain better. Here is what I have thus far. $result = mysql_db_query($database, "select refid, count(*) from aff_productsales WHERE adid = '".$_SESSION['aff_valid_admin']."' AND number = '$change' GROUP BY refid") or die ("Database Error"); if (mysql_num_rows($result)) { while ($qry = mysql_fetch_array($result)) { print "<font face=arial><TABLE border=1 cellspacing=0 cellpadding=3 align=center>"; print "<TR><TH>Refferer</TH><TH>Click Count</TH>"; print "</TR>"; print "<TR>"; print "<TD><font size=2>"; print $qry[refid]; print "</TD>"; print "<TD><font size=2>"; print "xxxxx"; print "</TD>"; print "</TR>"; print "</TABLE>"; } } PHP: what would xxxx value be?
select refid, count(*) as 'my_counter' from aff_productsales WHERE adid = '".$_SESSION['aff_valid_admin']."' AND number = '$change' GROUP BY refid" so your colname becomes 'my_counter' and you can use $qry['my_counter']. $qry[refid] should also be $qry['refid'], along with some other bad practises in your code (font tags? uppercase tags? no database class/functions?)
thanks, that worked. I appologise if my code offends, I'm part time self taught. But I appreciate your help. I'll fix what you mentioned.