<?php
$inum = mysql_num_rows($iquery);
for ($x=1;$x<=$inum;$x++) {
$irow = mysql_fetch_row($iquery);
$image = $image_dir . $irow[2] . ".jpg";
$dimension = getimagesize($image);
?><img src="<?php echo $image_dir . $irow[2] . ".jpg"; ?>" title="<?php echo $irow[1]; ?>" style="padding: 0 5px; width:"<?php echo $dimention[0]; ?>px; height:"<?php echo $dimension[1]; ?>;px" /><?php
}
?>
This code successfully outputs multiple lines as required:
<img src="http://www.example.com/images/jessica-01.jpg" title="Jessica" style="padding: 0 5px; width:879px; height:400px;" />
My problem is that I don't know where OR how to create a bit of code, which will add up all the widths ( dimension[0] ) into a single value. I have looked into count() and a few other things, but nothing sticks up.
Here say I have 4 images, which this code will put next to each other, having a dimension[0] value (width) of 200, 400, 400, 300. How could I get dimension[0] to then create a new variable, "total_width" and make its value 1300?
I hope this makes sense, and I appreciate in advance the assistance of you all.
Skaype