Click to See Complete Forum and Search --> : PHP pop up


tholman
08-05-2008, 04:06 PM
Have the following code working absolutely fine, but....

Would like the image to pop up in a new window, preferably using javascript (perhaps lightwindow)

How would I place the javascript class within the "echo "<a href=\" section?

Any help greatly appreciated

*******CODE*************

<?php
mysql_select_db ('rrrrrr');
$num_displayed = 1;
$result = mysql_query ("SELECT * FROM rrrrrrr ORDER BY RAND() LIMIT $num_displayed");
while ($row = mysql_fetch_array($result))
{
echo "<a href=\"" . $row["link"] . "\">
<img src=\"" . $row["image"] . "\" border=0 alt=\"" . $row["text"] . "\">
</a>" ;
?>

SyCo
08-05-2008, 05:06 PM
Add your jS event and have it call a function as in normal HTML.

eg

echo "<a href...etc... onclick=\"openWindowFunc(".$row['imageid'].")\">

tholman
08-05-2008, 06:46 PM
Okay

Managed to get external javascript linking through changing javascript files to .php and adding appropriate <?php ?>

Still unsure where to put the 'class' though

Thanks:

<?php
mysql_select_db ('dp');
$num_displayed = 1;
$result = mysql_query ("SELECT * FROM links ORDER BY RAND() LIMIT $num_displayed");
while ($row = mysql_fetch_array($result))
{
echo "<a href=\"" . $row["link"] . "\">
<img src=\"" . $row["image"] . "\" border=0 alt=\"" . $row["text"] . "\">
</a>" ;
?>

echo "<a href...etc... onclick=\"openWindowFunc(".$row['imageid'].")\">

class="lightwindow"

SyCo
08-05-2008, 07:19 PM
My advice would be to get this working on a non php page first with a simple test image, then you can try to get the database to provide the images.

http://www.stickmanlabs.com/lightwindow/#howtouse