MDanz Posted June 2, 2010 Share Posted June 2, 2010 $rvote = mysql_query("SELECT * FROM `Reply` WHERE keywords='$search'"); $rfound = mysql_num_rows($rvote); while($maxrow = mysql_fetch_assoc($rvote)) { $pos = $maxrow['Positive']; $neg = $maxrow['Negative']; $totalvotes=$pos+$neg; $count1 = $pos / $totalvotes; $count2 = $count1 * 100; $totalcount = number_format($count2, 0); } i want to echo the highest $totalcount of the loop. How do i do that? Link to comment https://forums.phpfreaks.com/topic/203602-select-highest-value-in-loop/ Share on other sites More sharing options...
dabaR Posted June 3, 2010 Share Posted June 3, 2010 $rvote = mysql_query("SELECT * FROM `Reply` WHERE keywords='$search'"); $rfound = mysql_num_rows($rvote); $max_totalcount = 0; while($maxrow = mysql_fetch_assoc($rvote)) { $pos = $maxrow['Positive']; $neg = $maxrow['Negative']; $totalvotes=$pos+$neg; $count1 = $pos / $totalvotes; $count2 = $count1 * 100; $totalcount = number_format($count2, 0); if ($totalcount > $max_totalcount) $max_totalcount = $totalcount; } echo $max_totalcount; Link to comment https://forums.phpfreaks.com/topic/203602-select-highest-value-in-loop/#findComment-1067014 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.