Or another way if you don't want a result when it's zero.
$rslt = mysql_query("SELECT count(*) as cnt FROM tbl having cnt > 0");

HTH..
Have a great day..
Dan

Rasmus Lerdorf wrote:
> $ret = mysql_query("SELECT count(*) as foo FROM AuthNum");
> $result = mysql_fetch_array($ret);
> echo $result['foo'];
> 
> One of many ways...
> 
> -Rasmus
> 
> 
> 
> On Wed, 2 Oct 2002, DonPro wrote:
> 
> 
>>Hi,
>>
>>I need to do either an insert or update into a MySQL table.  Insert if there
>>are 0 records or update if one record exist:
>>
>>This is my code snippet:
>>
>>if (mysql_query("SELECT COUNT(*) FROM AuthNum") == 0) {
>>   mysql_query("INSERT into AuthNum (FirstNum, LastNum, NextNum) VALUES
>>(1,2,3)",$dblink);
>>} else {
>>   mysql_query("Update AuthNum Set FirstNum = 1, LastNum = 2, NextNum =
>>3",$dbLink);
>>}
>>
>>My problem is, a record never gets inserted because the SELECT COUNT query
>>is returning a resource ID of 2.  How can I get the actual number of records
>>in the table?
>>
>>Thanks,
>>Don
>>
>>
>>
>>--
>>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