I'm a php beginner and trying to make aggregation for specific columns in mysql db table but there is a comma separated values in this columns so the result not correct. this is a sample of table columns
column1
12,345.67
123,456.78
column2
12,345.67
123,456.78
column3
12,345.67
123,456.78
column4
12,345.67
123,456.78
please find my code below and Kindly advice if I'll use a solution how I can use it.
<?php
$query=mysql_query("select * from mytable")or die(mysql_error());
while($row=mysql_fetch_array($query)){
?>
<tr>
<td><?php echo $row['column1'] ?></td>
<td><?php echo $row['column2'] ?></td>
<td><?php echo $row['column3'] ?></td>
<td><?php echo $row['column4'] ?></td>
</tr>
<?php } ?>
</tbody>
</table>
<?php
$result = mysql_query("SELECT sum(column1 + column2 + column3 + column4) FROM mytable") or die(mysql_error());
while ($rows = mysql_fetch_array($result)) {
?>
<div>
Total: <?php echo $rows['sum(column1 + column2 + column3 + column4)']; ?></div>
<?php }
?>
<?php }
?>