PDA

View Full Version : open browser popup from thumbnails


codeclown
02-27-2006, 09:41 AM
I'm a php newbie,
trying to create a product catalogue from an SQL DB, (adapted from the Janet Valades famous Pet shop example)

I want to open up a new browser window showing full size product images
from the thumbnail.

The thumbnail images are generated from a $row query I want to href these thumbnails with the popup link and pass the large image variable to the pop up window for each $row, but it's not havin' it, any ideas please?

The coded page is here

http://www.austingardner.com/2903globe/Showglobes2.php?categ=Wicket%20Keeping

the relevant code looks like this

if ( $ncolors <= 1 )
{

//display row for each color if product comes in one color only//
echo "<td class='bodytext'><a href='#' onClick='MM_openBrWindow('prodpop.php?image={$row['pix']}','Globesports','width=550,height=550')'>
<img src='{$row['pixthumb']}' class='thumbnail'
width='130' height='120'></a></td>\n";
}

// display row for each color if product comes in colors //
if ($ncolors > 1 )
{
while($row2 = mysql_fetch_array($result2,MYSQL_ASSOC))
{
echo "<tr><td colspan=2>&nbsp;</td>
<td class='bodytext'>{$row2['globeColor']}</td>
<td><<a href='#' onClick='MM_openBrWindow('prodpop.php?image={$row2['pix']}','Globesports','width=550,height=550')'>
<img src='{$row2['pixthumb']}' class='thumbnail'
width='130' height='120'></a></td>\n";
}
}
echo "<tr><td class='bodytext' colspan='5'><hr size='1px' class='rule'></td></tr>\n";
}

degsy
02-27-2006, 03:26 PM
This is a javascript problem.
Your syntax is wrong.

e.g.

echo "<tr><td colspan=\"2\">&nbsp;</td>
<td class=\"bodytext\">{$row2['globeColor']}</td>
<td><<a href=\"#\" onClick=\"MM_openBrWindow('prodpop.php?image={$row2['pix']}','Globesports','width=550,height=550')\">
<img src=\"{$row2['pixthumb']}\" class=\"thumbnail\"
width=\"130\" height=\"120\"></a></td>\n";


So you get an output of

onClick="MM_openBrWindow('prodpop.php?image={image=WK-KO-1.jpg','Globesports','width=550,height=550')">

StupidRalph
02-27-2006, 09:19 PM
I always try to write my javascript and debug it then have my PHP write it out after I perfected my javascript.

codeclown
02-28-2006, 08:39 PM
that sorted it, didn't know you could use \" to replace '
nice one:thumbsup:

degsy
03-01-2006, 02:51 PM
Personally I wouldn't have done it that way, but i was just making quich changes to your script.

I would output the correct HTML adding in the PHP variables

e.g.

<?php
$url = 'http://www.google.com';
$url_title = "Visit Google's page";
?>
<a href="<?php echo $url; ?>"><?php echo $url_title; ?></a>

Especially handy when you have alot of HTML and only a few variables.