Jump to content

A little help needed with simple problem: pop-up image


jw_d

Recommended Posts

I'd really appreciate any help someone could lend... I've tried 100 different ways to make this happen, but keeping getting screwed up.

 

I have a script which shows small images. What I want to do is for the user to click the photo and it enlarge in a pop-up screen. The page already exist for it to pop up in (view_image.php), but I just can't get it to open that window.

 

Here's the code:

<?php
$sql="select image from inputinfo where id='$id'";
$rez=mysql_query($sql,$dblnk);
$row=mysql_fetch_array($rez);
if($row['image']=="" && $row['image']=="") {}else{
echo "<img src='admin/{$row['image']}' width='100' height='60' border='1' />";
}
?>

 

Here's where I tried to modify it and script stalls out (I inserted the onclick):

<?php
$sql="select image from inputinfo where id='$id'";
$rez=mysql_query($sql,$dblnk);
$row=mysql_fetch_array($rez);
if($row['image']=="" && $row['image']=="") {}else{
echo "<img src='admin/{$row['image']}' width='100' height='60' border='1' 

onclick="window.open('view_image.php?id=<? echo $id;?>','mywindow','menubar=1,resizable=1,width=550,height=550')"

/>";
}
?>

 

Thanks SO MUCH for any help!

Link to comment
Share on other sites

I went in there and added the quote, but the page still loads blank... I'm using IE and no js errors show.

 

Here's what I changed it to:

 

<?php
$sql="select image from inputinfo where id='$id'";
$rez=mysql_query($sql,$dblnk);
$row=mysql_fetch_array($rez);
if($row['image']=="" && $row['image']=="") {}else{
echo "<img src='admin/{$row['image']}' width='100' height='60' border='1' 

onclick="window.open('view_image.php?id=<? echo $id;?>','mywindow','menubar=1,resizable=1,width=550,height=550')"

/>";
}
?>

 

EDIT: Not sure why... the single quote ' is there before view_image but not displaying on here for some reason

Link to comment
Share on other sites

You're right, i can see the quote in the source of your post but not when it's displayed .. maybe a bug in phpfreaks.

 

The code looks ok to me .. one approach you could try is finding a website that successfully pops up a window for you, and copying their code (or examining it to see how it differs from yours)

Link to comment
Share on other sites

may i suggest lightbox

 

its a javascript cross browser compatible thing,

it doesnt open in a "new window" so it is not screwed over by popup blockers, but it appears clearly.

its used successfully on many large sites and is becoming sort of a standard,

 

but as an example

 

heres trademe (new zealands version of ebay) they use it,

 

click on one of the pictures to see what i mean

 

ps this is just some random auction

 

http://www.trademe.co.nz/Antiques-collectables/Alcohol-related/Beer-related/Other/auction-201359308.htm

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.