I am trying to make a div ID have a unique name by using a variable to iterate through the number of times it gets looped. For some reason my $k variable doesn't seem to be advancing. Here is the code:
<?php foreach($files as $media)
{
$k = 0;
?>
<h3><?php echo $output[$j] ?></h3>
<div id='mediaspace<?php echo $k ?>'>This text will be replaced</div>
<script type='text/javascript'>
...
so.write('mediaspace<?php echo $k ?>');
</script>
<?php
$k = $k+1;
} ?>
My HTML output just gives me a 0 for $k every time the loop is run:
<div id='mediaspace0'>This text will be replaced</div>
<script type='text/javascript'>
... so.write('mediaspace0');
</script>
<h3>Rattletree Marimba Day</h3>
<div id='mediaspace0'>This text will be replaced</div>
<script type='text/javascript'>
... so.write('mediaspace0');
</script>
Any help greatly appreciated!