MoMoMajor Posted July 24, 2009 Share Posted July 24, 2009 ok so I am having trouble displaying an image in a certain location after an anchor tag is clicked. I have a while loop taking image information from mysql and displaying it in a div that is then styled by css. I want to be able to click one of these images and have that image appear in another div that is located on top of the loop code, while still having the gallery being displayed at the bottom. <?php $directory = "pics/".$page_url."/"; $filecount = count(glob("" .$directory. "*.jpg")); if ($filecount > 0) { while($row = mysql_fetch_array($result)){ echo "<a href='#' class='imagelinks'><img class='returnimg' src='pics/".$page_url."/".$row['file_name']."'/></a>"; }} else { echo "There are no images to display in this gallery"; } ?> is there a way to do this? Link to comment https://forums.phpfreaks.com/topic/167209-need-help-with-image-display/ Share on other sites More sharing options...
rhodesa Posted July 24, 2009 Share Posted July 24, 2009 try <img id="preview" src="" /> <?php $directory = "pics/".$page_url."/"; $filecount = count(glob("" .$directory. "*.jpg")); if ($filecount > 0) { while($row = mysql_fetch_array($result)){ $src = 'pics/'.$page_url.'/'.$row['file_name']; echo '<a href="#" class="imagelinks" onclick="document.getElementById(\'preview\').src = \''.$src.'\';return false;"><img class="returnimg" src="'.$src.'" /></a>'; } } else { echo "There are no images to display in this gallery"; } ?> Link to comment https://forums.phpfreaks.com/topic/167209-need-help-with-image-display/#findComment-881987 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.