if ($array = mysql_fetcharray($result))
{    echo $array["SUM( hide = 0 )"];
}

although for readability I'd prefer an 
" AS sum_hide " in the query and then use 
$array["sum_hide"]

in general for reading from a mysql result ...

// for a single return row (or the just the first row)
if ($result = mysql_query("..."))
{    if ($array = mysql_fetch_array($result))
    {    ...
    }
}

// for multiple return rows
if ($result = mysql_query("..."))
{    while ($array = mysql_fetch_array($result))
    {    ...
    }
}

Tim Ward
http://www.chessish.com
mailto:[EMAIL PROTECTED]
----- Original Message ----- 
From: rentAweek support <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 27, 2003 5:31 PM
Subject: [PHP] Counting table fields having specific values


>   I have a table where the row named "hide" can have a value 0 or 1.
> I want to obtain a count of all the rows where "hide" has value 0.
> 
> The following works on mysqladmin:
> 
> SELECT SUM( hide = 0 ) FROM `names` LIMIT 0, - 1 
> 
> Giving
> 
> SUM( hide = 0 ) 
> 7
> 
> The PHP script statements generated are:
> 
> $sql = 'SELECT SUM( hide = 0 ) FROM `names` LIMIT 0, -1';
> $result = mysql_query($sql);
> 
> What assignment statement do I need to write now to obtain the SUM value 
> as shown by mysqladmin please?
> 
> TIA
> 
> Mike
>  
> 
> 
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 
> 


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

Reply via email to