djfox Posted September 20, 2007 Share Posted September 20, 2007 I have the following codes: <?php $total = $rows[8] + $rows[9] + $rows[10] + $rows[11] + $rows[12] ; $per1 = $rows[8]/$total ; $per2 = $rows[9]/$total ; $per3 = $rows[10]/$total ; $per4 = $rows[11]/$total ; $per5 = $rows[12]/$total ; if (isset($_GET['results']) && $_GET['results'] == "view") { echo "<b>Results:</b>"; echo "<br>$rows[3] <b>$rows[8]</b><br><font size=2>$per1 %</font>"; echo "<br>$rows[4] <b>$rows[9]</b><br><font size=2>$per2 %</font>"; echo "<br>$rows[5] <b>$rows[10]</b><br><font size=2>$per3 %</font>"; echo "<br>$rows[6] <b>$rows[11]</b><br><font size=2>$per4 %</font>"; echo "<br>$rows[7] <b>$rows[12]</b><br><font size=2>$per5 %</font>"; echo "<p>$total Votes"; } ?> How can I convert the $per values to display as percentages? Currently they display as 0.5 and so on. Link to comment https://forums.phpfreaks.com/topic/70067-solved-quick-php-convert-to-percentages/ Share on other sites More sharing options...
BlueSkyIS Posted September 20, 2007 Share Posted September 20, 2007 multiply by 100 and add a % sign... Link to comment https://forums.phpfreaks.com/topic/70067-solved-quick-php-convert-to-percentages/#findComment-351866 Share on other sites More sharing options...
djfox Posted September 20, 2007 Author Share Posted September 20, 2007 Thanks very much. Link to comment https://forums.phpfreaks.com/topic/70067-solved-quick-php-convert-to-percentages/#findComment-351881 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.