Welcome to Dream.In.Code
Become a PHP Expert!

Join 150,170 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,294 people online right now. Registration is fast and FREE... Join Now!




View image in web page

 
Reply to this topicStart new topic

View image in web page

jonny2608
24 Aug, 2008 - 02:38 AM
Post #1

New D.I.C Head
*

Joined: 7 Dec, 2006
Posts: 2


My Contributions
Hey, I'm new to php and have been trying to do this very simple thing but am having no luck.

All I want is when I click on a link to open an image, rather than just opening the image in a browser, I want to display it within a new webpage in say a div for example.

This is what I have so far, it basically loads images from a thumbnail directory, and contains a link to display the related photo image.

CODE

<?php

function PhotoGallery()
{
  $thumbnails = glob("images/thumbnails/*.*");
  $photos = glob("images/photos/*.*");
  
  $j = 0;
  
  foreach($thumbnails as $thumbnail)
  {
    echo "<div id = \"thumbnail\">";
    $i++;
    
      echo "<a href=\"" . $photos[$j] . "\" target=\"_self\">";

      echo "<img src=\"" . $thumbnail . "\" alt = \"\" title = \"\">";
      echo "</a>";
    
    echo "</div>";
    
    $j++;
    
    if($i >= 5)
    {
      echo "<br />";
      $i = 0;
    }
  }
}

?>


All I need is to make the links to pass the path to the photo to another web page to display it there.

Thanks!
User is offlineProfile CardPM
+Quote Post

JBrace1990
RE: View Image In Web Page
24 Aug, 2008 - 06:54 AM
Post #2

D.I.C Regular
Group Icon

Joined: 9 Mar, 2008
Posts: 479



Thanked: 24 times
Dream Kudos: 350
My Contributions
you'll want to use $_GET on the recieving page, and urlencode for the sending page...

that, or if the images are all in the same spot, set up something like this:

php
<?php
$get $_GET['id'];
echo "<img src=\"http://site.com/images/".$get.".jpg\";
?>


or hold them in a database, pull the records, and echo it...
User is offlineProfile CardPM
+Quote Post

jonny2608
RE: View Image In Web Page
25 Aug, 2008 - 12:17 AM
Post #3

New D.I.C Head
*

Joined: 7 Dec, 2006
Posts: 2


My Contributions
Thanks, I've almost got it to work now.

I've got another problem that's unrelated now, but at least I can pass a variable (i.e the file name) between pages. biggrin.gif
User is offlineProfile CardPM
+Quote Post

JBrace1990
RE: View Image In Web Page
25 Aug, 2008 - 10:42 AM
Post #4

D.I.C Regular
Group Icon

Joined: 9 Mar, 2008
Posts: 479



Thanked: 24 times
Dream Kudos: 350
My Contributions
lol, it's no problem, always here to help happy.gif
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 03:05AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month