Re: Getting a result from MAX() query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"John W. Holmes" <holmes072000@xxxxxxxxxxx> wrote in message
news:40F3F535.10007@xxxxxxxxxxxxxx
> boclair@xxxxxxxxxxx wrote:
> > Would somebody be kind enough to explain why this query produces a false
result
> >
> > $latest=mysql_query("SELECT MAX(fee_recd) FROM members",$connectup)or
die
> > ("Query failed:<br>$latest<br>Error: " . mysql_error());
>
> Would you be kind enough to tell us what text mysql_error() shows?
>
> You probably just need to use an alias in your query:
>
> SELECT MAX(fee_recd) AS max_fee_recd FROM members
>
> and then you'll have $row['max_fee_recd'] when you fetch the value from
> your result set. Other wise you need to use $row['MAX(fee_recd)']...

I did reply but it seems to have gone astray.

Thanks.  There no report from error() and obviously the result of the query
is not false.  I was trying to solve the wrong problem which was in the PHP
statement that followed.  Using your example, this was successful

$latest=mysql_query("SELECT MAX(fee_recd) FROM members",$connectup)or die
("Query failed:<br>$latest<br>Error: " . mysql_error());

while ($myrow= mysql_fetch_array($latest)){
$recentpaid=$myrow['MAX(fee_recd)'];
}

Louise

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux