karimali831 Posted November 4, 2010 Share Posted November 4, 2010 Hi, Example: echo percent(5, 10, 2)."%"; gives you 50% Instead of this representation, I want to use a bar like this: So what ever percentage it is, it will show on the bar. (out of 100%) anyone help me achieve this please? Thanks function percent($sub, $total, $dec) { if ($sub) { $perc = $sub / $total * 100; $perc = round($perc, $dec); return $perc; } else return 0; } Link to comment https://forums.phpfreaks.com/topic/217794-php-percent/ Share on other sites More sharing options...
waynew Posted November 4, 2010 Share Posted November 4, 2010 You can do this using CSS. Set the main container: <div style="width:100px; background-color:#fff; border:#eee 1px solid; height:30px;"> <div style="width:<?php echo $percent; ?>%; background-color:#eee;"> <> <> Link to comment https://forums.phpfreaks.com/topic/217794-php-percent/#findComment-1130459 Share on other sites More sharing options...
karimali831 Posted November 4, 2010 Author Share Posted November 4, 2010 Now I get the CSS right, but it don't show the percent: $ratio = '<div style="width:'.$challenger_ratio.'%; background-color:#333333;">'; http://team-x1.co.uk/site/index.php?site=standings&ladderID=16 Thanks for help! Link to comment https://forums.phpfreaks.com/topic/217794-php-percent/#findComment-1130472 Share on other sites More sharing options...
karimali831 Posted November 4, 2010 Author Share Posted November 4, 2010 Me being daft, solved it. Thanks!! Link to comment https://forums.phpfreaks.com/topic/217794-php-percent/#findComment-1130473 Share on other sites More sharing options...
waynew Posted November 4, 2010 Share Posted November 4, 2010 Ah! A fellow COD player Link to comment https://forums.phpfreaks.com/topic/217794-php-percent/#findComment-1130474 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.