You are here: Re: mysql_fetch for aggregate SQL function « PHP Programming Language « IT news, forums, messages
Re: mysql_fetch for aggregate SQL function

Posted by Steve on 09/19/05 00:58

> $query = "select max(qno) from answers";
> $result = mysql_query($query);

> $maxqno = mysql_result($result);

> $nextqno = $result + 1;

mysql_result() needs a minimum of two arguments: resource and row
number.

Alternatively, use an alias for the aggregate column and get it by
name:

$query = "select max(qno) as maxqno from answers";
$result = mysql_query( $query );

$row = mysql_fetch_array( $result, MYSQL_ASSOC );
print $row[ 'maxqno' ];

---
Steve

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация