![]() |
Attachment Count in MB
Can anyone please tell me how to pull the MB out of an attachment query? Here is the code for pulling out the KB but I can't seem to find the right code for the MB. I know it is simple, but I must not be very good in the math department.
PHP Code:
|
PHP Code:
|
I had that but I want to get it like 2.12 MB. instead of just 2 MB. How do I get it to go the 2 decimal places?
|
<a href="http://www.php.net/round" target="_blank">http://www.php.net/round</a>
|
I tried that, too. When I round 2,174,891, I get 2 MB. This is how I used round:
PHP Code:
|
Then:
[sql] ...SUM(LENGTH(attachment.filedata)) / 1024 * 1024 * 1024 AS mbytesum... [/sql] ...then round it. :) |
That threw it way off. ;) Here's the code I am working with if that will help.
PHP Code:
|
Use the php modulus operator to work with the remainder.
http://us3.php.net/manual/en/languag...arithmetic.php |
LOL I just tried that and I was way off. All I am trying to do is go 2 decimal places with the MB and have it rouind up if it needs to.
|
Okay, get the sum in bytes, and assume it's in the $bytes variable.
PHP Code:
|
I have something like that here:
PHP Code:
|
It won't round at all, probably.
|
Is there any way to make it round up or is what I got the best I can get?
|
<a href="http://www.php.net/round" target="_blank">http://www.php.net/round</a>
|
Quote:
|
And it doesn't work?
|
No, it rounds 2.12 MB to 2 MB and if I use number_format(attachsmb), 2), then it rounds it to 2.00. It must be the way I am trying to cache it.
|
round will still work. Look at the second argument.
|
Quote:
|
PHP Code:
|
Already tried that and it doesn't work either.
|
There was a fine solution in HiveMail,
Chen is a really perfect php coder - clean and nice. |
Nobody's a perfect coder...
|
Nope, I doen't believe you, Fil.
Chen has coded this and that and it's all so smooth, the functions and, oh, I just love it. |
Quote:
You see, gmarik, nobody is perfect. |
That all depends on your idea of perfection. Maybe perfection for him [high]IS[/high] Chen's coding ability. Nothing wrong with that.
|
All times are GMT. The time now is 12:18 AM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|