Hi
I have a PHP script that pulls images into a repeating div which works great. I'm trying to make it so that when you click on the div it pops up a window via javascript. The problem I have is that the onclick event always pulls out the last image the page loaded instead of being part of the PHP loop. How can I make it display the relevant image rather than the last image in the loop?
Also, how do you make code appear as such in these posts?
Thanks very much for looking
<div id="content">
<!-- Content Window -->
<?php do { ?>
<script>
function myfunction(){TINY.box.show(content2,0,0,0,1)}
var content2 = "<img src='<?php echo $fullpath?>' width='298' height='373' alt='' />";
</script>
<?php
$mypath1 = $row_rs_images['path'];
$mypath2 = $row_rs_images['category'];
$mypath3 = $row_rs_images['image'];
$sep = "/";
$fullpath = $mypath1.$sep.$mypath2.$sep.$mypath3;
?>
<div id="image" onClick="myfunction();">
<img src="<?php echo $fullpath ?> "width="100" height="100"/><?php echo $row_rs_images['description']; ?>
<?php echo $fullpath;?>
</div>
<?php } while ($row_rs_images = mysql_fetch_assoc($rs_images)); ?>
</div>
I have a PHP script that pulls images into a repeating div which works great. I'm trying to make it so that when you click on the div it pops up a window via javascript. The problem I have is that the onclick event always pulls out the last image the page loaded instead of being part of the PHP loop. How can I make it display the relevant image rather than the last image in the loop?
Also, how do you make code appear as such in these posts?
Thanks very much for looking
<div id="content">
<!-- Content Window -->
<?php do { ?>
<script>
function myfunction(){TINY.box.show(content2,0,0,0,1)}
var content2 = "<img src='<?php echo $fullpath?>' width='298' height='373' alt='' />";
</script>
<?php
$mypath1 = $row_rs_images['path'];
$mypath2 = $row_rs_images['category'];
$mypath3 = $row_rs_images['image'];
$sep = "/";
$fullpath = $mypath1.$sep.$mypath2.$sep.$mypath3;
?>
<div id="image" onClick="myfunction();">
<img src="<?php echo $fullpath ?> "width="100" height="100"/><?php echo $row_rs_images['description']; ?>
<?php echo $fullpath;?>
</div>
<?php } while ($row_rs_images = mysql_fetch_assoc($rs_images)); ?>
</div>