Usage Display Summarization


When displaying a customers usage, to automatically summarize it in to MBs/GBs/TBs


  1. Change heading title from Upload/Download MB to just Upload/Download
  2. Display MB / GB or TB

Simple Example:

if ($usage < 1000) { $display = "MB"; }
elseif (($usage >= 1000) && ($usage < 10000)) { $display = "GB"; $usage = $usage / 1000; }
elseif ($usage >= 10000) { $display = "TB"; $usage = $usage / 10000; }

print "$usage $display\n";



good to think:
It’s good if you have one record …
but please think about table mixed values,

Kb, Mb, Gb, TB, Pb? )

how to sort it, show correct … ? )

this is Table.


The database value would remain the same and not changed, it would just be that when the value is displayed on the stats page that it is adjusted to something more readable.


As i see on screenshot you talking about TABLE (with online customers)

and one customer online can be 10 Kb
and on other customer can be 10 GB
now we will see 0.01 , and 10000 and that’s is not bad.
or in case we will define GB we will see 0.00 and 10 … ?

on tables data should be normalized … to something one …


Yes, the idea was to only change the display of data as the table data is presented on the page. If the query to the DB returns a list of all customers with their data, it would run through a for loop, for each line on the page. At this point you could update the display of the usage data as per my example. The table name can remain as Upload/Download, but each line can be parsed to display the shortened version.

In terms of sorting, this might be a little more difficult to achieve granted. Maybe looking at only displaying GB’s would be a way as you pointed out above. The main idea is to reduce the number count to assist in the visibility of what data the user has transferred.