Page 1 of 1

Finding the highest value - newbie question

Posted: Tue Dec 30, 2003 6:20 pm
by ade
Hi,

I'm new to php and I'm trying to build a small MySQL application for my website.

I need to find the highest numeric value (integers)in a table column. so far I have let Dreamweaver MX help me define a recordset which I can see works ok. Next I tried to use the max() function on the recordset which I believe should work as the recordset is an array.

I tried:
$maxnumber = max($recordset);
but that gave me errors when it ran.

Next I tried:
$maxnumber = max(array(recordset));
which, when echoed tells me that the value in $maxnumber is not an integer as I was expecting but the string "Resource id #2".

Please can someone help me to get the highest integer out of the table column. Do I need to define a recordset first? Am I using the wrong syntax? I have tried the online php docs but am not having much luck.

Thanks in advance.

ade
uk

Posted: Tue Dec 30, 2003 7:03 pm
by Straterra

Posted: Wed Dec 31, 2003 1:43 am
by swirlee
Why not just use MySQL's MAX() function?

Posted: Wed Dec 31, 2003 4:47 am
by ade
Thanks both. Now I knew what to look for I have found all the SQL function docs. MAX() does exactly what I need.

ade
uk