954,585 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Sum all the values in one colum of a html table?

Hi

This may not be a php matter but i'm wondering if it can be done?

I have a table like the following:

<table>
<tr>
<td>1</td>
<td>2</td>
</tr>

<tr>
<td>7</td>
<td>9</td>
</tr>

<tr>
<td><<SUM OF THIS COLUMN (8)>></td>
<td><<SUM OF THIS COLUMN(11)>></td>
</tr>
</table>


I hope you understand what it is im asking. This is easy to do in mysql however can it be done in standard html/dhtml ?

Thanks

Designer_101
Posting Whiz
314 posts since Jul 2007
Reputation Points: 12
Solved Threads: 16
 

if the data values were populated by PHP and the HTML gnerated by PHP, the sums can be calculated with a for loop.

if this is just a plain HTML somefile.html, then at best you can use clientside scripting like javascript to traverse the table DOM and get the .value of the td, do a sum and then set the .value again for the final row.

jakesee
Junior Poster
130 posts since Jul 2008
Reputation Points: 21
Solved Threads: 5
 

just with html its not possible use javascript or php for calculation. if you need help about javascript or php calculation let me know.

BzzBee
Posting Whiz
327 posts since Apr 2009
Reputation Points: 16
Solved Threads: 48
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You