/    Sign up×
Community /Pin to ProfileBookmark

Calculate the total sizes of a file in a row

I have in a table filenames and sizes
but don’t know how to calculate the total file size in the row
example
filename. File size
file1———2098656
file2———5637484
file3———6788977
i want to calculate the file size in a loop

to post a comment
PHP

5 Comments(s)

Copy linkTweet thisAlerts:
@NogDogAug 18.2019 — We'll need to know how it's stored in the code (e.g. array structure?), or are you looking for a SQL approach, or what? If it's in some sort of array, just loop on it and increment a variable:
<i>
</i>$total = 0;
foreach($data as $row) {
$total += $row['file_size']; // or whatever it's called
}
echo "Total is: $total";
Copy linkTweet thisAlerts:
@ginerjmAug 18.2019 —  When you say "in a table" is this a database table or an HTML table?
Copy linkTweet thisAlerts:
@siddhi_patelAug 22.2019 — Hey... if u use sql then it is like this.

$Total = 0;

foreach($data as $row){

$Total += $row['file_size'];

}

echo "Total is : $Total";
Copy linkTweet thisAlerts:
@RichardSusskind1Aug 27.2019 — As the resolution and bit depth of digital detectors continue to improve, the user often gets excited about the improved image quality. Your IT person however may not share your enthusiasm when they see the size of the files being stored. One quick way to calculate the file size of your new system is to calculate the total number of pixels in the detector, multiply that by the number of bits of bit depth and divide the result by 8 (because there are 8 bits in a byte)
Copy linkTweet thisAlerts:
@ginerjmAug 27.2019 — I don't think the question was about how to determine the size of things.... But - I have mis-read some posts myself.
×

Success!

Help @Richard_Obiri spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.9,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...