/    Sign up×
Community /Pin to ProfileBookmark

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))
{
[COLOR=”Red”] echo “<a href=”” . $row[“link”] . “”>
<img src=”” . $row[“image”] . “” border=0 alt=”” . $row[“text”] . “”> [/COLOR]

</a>” ;
?>

to post a comment
PHP

3 Comments(s)

Copy linkTweet thisAlerts:
@SyCoAug 05.2008 — Add your jS event and have it call a function as in normal HTML.

eg
[code=php]
echo "<a href...etc... onclick="openWindowFunc(".$row['imageid'].")"> [/code]
Copy linkTweet thisAlerts:
@tholmanauthorAug 05.2008 — 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"[/QUOTE]
Copy linkTweet thisAlerts:
@SyCoAug 06.2008 — 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
×

Success!

Help @tholman spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...