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'; } 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 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 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']; Link to comment https://forums.phpfreaks.com/topic/50129-solved-find-highest-value/#findComment-246298 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.