rank bar
Posted: Sat Jun 18, 2005 4:52 pm
how would one make a rank bar so it goes from -100% to 100%?
would you use javascript?
would you use javascript?
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
<table id="e;xp_bar"e; class="e;status_bar"e;>
<colgroup span="e;100"e; width="e;1"e; class="e;unit_percentPoint"e;></colgroup>
<caption id="e;xp_bar_textual"e;>10023 experience points, 48% of required points until next level.</caption>
<thead id="e;xp_bar_legend"e;>
<tr><td colspan="e;10"e;>0%</td><td colspan="e;10"e;>10%</td><td colspan="e;10"e;>20%</td><td colspan="e;10"e;>30%</td><td colspan="e;10"e;>40%</td><td colspan="e;10"e;>50%</td><td colspan="e;10"e;>60%</td><td colspan="e;10"e;>70%</td><td colspan="e;10"e;>80%</td><td colspan="e;10"e;>90%</td>
</tr>
</thead>
<tbody id="e;xp_bar_visual"e;>
<tr>
<td colspan="e;48"e; id="e;xp_bar_visual_done"e;>&nbsp;</td>
<td colspan="e;52"e; id="e;xp_bar_visual_notdone"e;>&nbsp;</td>
</tr>
</tbody>
</table>Code: Select all
//Execute UNIX df command to read mounted disk info
$disk_data = (`df`);
$tot_size = 0;
$used_size = 0;
preg_match_all('/^.*?\s+(\d+)\s+(\d+).*$/m', $disk_data, $dm); //Extract relevant data
foreach ($dm[1] as $v) {
$tot_size += $v;
}
foreach ($dm[2] as $v) {
$used_size += $v;
}
//Disk information
$details['disk_size'] = round($tot_size/1024/1024 ,2) . 'GB';
$details['disk_usage'] = round($used_size/$tot_size * 100, 2) . '%';
$bar_pc = round($used_size/$tot_size * 100); //Percentage of disk space for bar graph
//A *sort of* bar graph using just CSS <----- the bit you need
$bar = '<div style="width:100%; border:1px solid #555555; height:10px; font-size: 7pt; text-align:left"><div style="font-size:7pt; height:10px; width:'.$bar_pc.'%; background-color:#E7FF7F; text-align:center">'.$details['disk_usage'].' used</div></div>';