The Arcive of vBulletin Modifications Site. |
|
Attachment Count in MB Details »»
|
|||||||||||||||||||||||||
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:
Show Your Support
|
|||||||||||||||||||||||||
| Comments |
|
#2
|
||||
|
||||
|
PHP Code:
|
|
#3
|
||||
|
||||
|
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?
|
|
#4
|
|||
|
|||
|
<a href="http://www.php.net/round" target="_blank">http://www.php.net/round</a>
|
|
#5
|
||||
|
||||
|
I tried that, too. When I round 2,174,891, I get 2 MB. This is how I used round:
PHP Code:
|
|
#6
|
|||
|
|||
|
Then:
[sql] ...SUM(LENGTH(attachment.filedata)) / 1024 * 1024 * 1024 AS mbytesum... [/sql] ...then round it.
|
|
#7
|
||||
|
||||
|
That threw it way off.
Here's the code I am working with if that will help.PHP Code:
|
|
#8
|
|||
|
|||
|
Use the php modulus operator to work with the remainder.
http://us3.php.net/manual/en/languag...arithmetic.php |
|
#9
|
||||
|
||||
|
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.
|
|
#10
|
|||
|
|||
|
Okay, get the sum in bytes, and assume it's in the $bytes variable.
PHP Code:
|
![]() |
|
|