Jump to content

select highest value in loop


MDanz

Recommended Posts

 
$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

 
$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;

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.