Jump to content

need help with image display


MoMoMajor

Recommended Posts

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

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";
  }
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.