MoFish Posted May 5, 2007 Share Posted May 5, 2007 Hello. Im trying to find the highest value of a value in my database called LeagueWoodenSpoon. On the highest value, i want to set $image="spoon.gif" i tryed the following code, but it adds a spoon.gif to everything over 0 and not only the highest value can anyone point me in the right direction? the following code is inwith a loop which goes through every value in my database. $SpoonFlag = 0; if($row_SelectAllLeague['LeagueWoodenSpoon'] > $SpoonFlag){ $SpoonFlag = $row_SelectAllLeague['LeagueWoodenSpoon']; $image='spoon.gif'; } Quote Link to comment https://forums.phpfreaks.com/topic/50129-solved-find-highest-value/ Share on other sites More sharing options...
taith Posted May 5, 2007 Share Posted May 5, 2007 http://www.tizag.com/mysqlTutorial/mysqlmax.php Quote Link to comment https://forums.phpfreaks.com/topic/50129-solved-find-highest-value/#findComment-246134 Share on other sites More sharing options...
MoFish Posted May 5, 2007 Author Share Posted May 5, 2007 echo "The most expensive is " . $row_SelectAllLeague['MAX(LeagueWoodenSpoon)']; Notice: Undefined index: MAX(LeagueWoodenSpoon) in D:\league.php on line 48 hmm Quote Link to comment https://forums.phpfreaks.com/topic/50129-solved-find-highest-value/#findComment-246136 Share on other sites More sharing options...
paul2463 Posted May 5, 2007 Share Posted May 5, 2007 try in your query a something like this $query = "SELECT *, MAX(LeagueWoodenSpoon) AS spoon FROM table"; echo "The most expensive is " . $row_SelectAllLeague['spoon']; Quote Link to comment https://forums.phpfreaks.com/topic/50129-solved-find-highest-value/#findComment-246298 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.