Create Static Page from JPEG

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Nytol
Forum Newbie
Posts: 13
Joined: Thu Jul 30, 2009 3:53 pm

Re: Create Static Page from JPEG

Post by Nytol »

I couldn't get what you showed me to work, but I have made some progress with your help with view.php.

My main_image div code looks like this now...

Code: Select all

<?php $p = $posts[0]; ?><a href="http://www.domain.com/view.php?n=<?php echo $p['image']; ?>"><img src="" /></a>
When I click a .jpg, in the main_image div, a new page opens (now with a header and footer...yay) and it works great. But, it loads the same image into the new page whatever image I click in the main_image div. I guess it's loading the first image in the array which I don't want.

The bit that is really confusing me is what to put after view.php?n= in my main_image div so that the corresponding image loads into the new page. I can't seem to get the a href information of the main image into view.php.

I was wondering if there was a way to scan the main_image div for the a href of the image, and put that information into some sort of PHP code? So then I would have view.php?n=<?php code ?>?

Edit: In fact, forget the <?php $p = $posts[0]; ?> that is for something else I need to run. I just have that so the first thumbnail of the first image shows when you initially load the page.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Create Static Page from JPEG

Post by jackpf »

I'm not sure I understand...

What's $p['image']?
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Create Static Page from JPEG

Post by pickle »

I think there's a simple solution here, but I want to make sure I know what you're trying to accomplish. This is what I've managed to piece together:

You've got a main page that has a bunch of thumbnails on it. When the user clicks a thumbnail, the image is loaded into the main_image div. When the user clicks that bigger photo in the main_image div, they are taken to the view.php?n=blah blah page that shows the image at full size.

Am I correct?
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Nytol
Forum Newbie
Posts: 13
Joined: Thu Jul 30, 2009 3:53 pm

Re: Create Static Page from JPEG

Post by Nytol »

Yep. Exactly.

thumbnail div - Bunch of thumbnails

main_mage div - A big image which appears after you click a thumbnail.

Both divs on index.php in the root of the webserver.

I got the code from a really cool banner rotator (http://www.sohtanaka.com/web-design/exa ... e-rotator/)

Now after the thumbnail has been clicked, and the full size image appears in the main_image div, I want visitors to be able to click the full size image again and be taken to a new page (view.php?n=blahblah) where the image will have it's own unique page. :)

I did a little research and maybe I could use preg_match to grab the first IMG SRC in the main_image div, and place that at the end of view.php?
Last edited by Nytol on Fri Jul 31, 2009 11:31 am, edited 2 times in total.
Nytol
Forum Newbie
Posts: 13
Joined: Thu Jul 30, 2009 3:53 pm

Re: Create Static Page from JPEG

Post by Nytol »

jackpf wrote:I'm not sure I understand...

What's $p['image']?
$p['image'] is the images stored in my database. I call these images into thumbnail div. It gets a little bit crazy because I also added an image resizer (image.php).

This is the code in my thumbnail div...

Code: Select all

<a href="http://www.domain.com/common/image.php<?php echo $p['image']; ?>/?width=659&height=1200&image=<?php echo $p['image']; ?>"><img src="<?php echo $p['thumb']; ?>"/></a>
So it takes the images already in my database, creates a new resized image for main_image div.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Create Static Page from JPEG

Post by pickle »

If the thumbnail stuff is working, then you obviously know in Javascript the filename you want to link to. Just give the <a> tag in your main_image div an ID, then in jQuery you can do this:

Code: Select all

var imagename = 'name_of_image.jpg';
$("#idoflink").attr('href','view.php?n='+imagename);
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
jackpf
DevNet Resident
Posts: 2119
Joined: Sun Feb 15, 2009 7:22 pm
Location: Ipswich, UK

Re: Create Static Page from JPEG

Post by jackpf »

Oh right. Didn't know that :oops:
Post Reply