Actually, using your original query and referring to

$row['count(*)']

would work too. However, when using calculated fields I always use a column alias as Rich recommends - it makes things a lot clearer.

-steve


At 1:54 PM +0000 11/13/02, "Rich Gray" <[EMAIL PROTECTED]> wrote:
try '... ,count(*) as count ...' then you should be able to reference it as
$row['count']
HTH
Rich
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:ed@;home.homes2see.com]
Sent: 13 November 2002 13:44
To: [EMAIL PROTECTED]
Subject: [PHP] PHP and MySQL sorting using COUNT



I'm sorting records using COUNT with the following mysql command

$result = mysql_query ("SELECT company_name, agent_name, count(*) FROM
$cur_listings GROUP BY company_name, agent_name");

Running this in MySQL does exactly what I need it to do but how do I echo
the COUNT portion of the array? I know the company_name would be
$row['company_name'] and agent_name is $row['agent_name'];

Thanks,

Ed Curtis

--
+------------------------------------------------------------------------+
| Steve Edberg                                      [EMAIL PROTECTED] |
| University of California, Davis                          (530)754-9127 |
| Programming/Database/SysAdmin               http://pgfsun.ucdavis.edu/ |
+------------------------------------------------------------------------+
| SETI@Home: 1001 Work units on 23 oct 2002                              |
| 3.152 years CPU time, 3.142 years SETI user... and STILL no aliens...  |
+------------------------------------------------------------------------+

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to