Finding the highest value - newbie question
Posted: Tue Dec 30, 2003 6:20 pm
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
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