Northern Flame Posted August 17, 2007 Share Posted August 17, 2007 I am designing a website for a photographer and on the template i have a section that shows his newest photos. The information of these photos is stored in a MySQL database with the columns, name src (Image Source ex: http://site.com/images/pic.jpg) id when a user clicks on an image i want a pop up window to apear with the image clicked on i know how to do this using javascript, <head> <script type="text/javascript"> <!-- function myPopup() { window.open( "http://www.google.com/", "myWindow", "status = 1, height = 300, width = 300, resizable = 0" ) } //--> </script> </head> <body> <img onClick="myPopup()" src="/images/pic.jpg"> </body> but how can i do add that into my script <?php $host = 'localhost'; $user = 'user'; $pass = 'pass'; $db = 'db'; @mysql_connect($host, $user, $pass) or die("ERROR--CAN'T CONNECT TO SERVER"); @mysql_select_db($db) or die("ERROR--CAN'T CONNECT TO DB"); $limit = 4; $query_count = "SELECT count(*) FROM ringtones"; $result_count = mysql_query($query_count); $totalrows = mysql_num_rows($result_count); $query = "SELECT * FROM ringtones ORDER BY id DESC LIMIT $limit"; $result = mysql_query($query) or die("ERROR " . mysql_error()); echo '<div id="gallery"> while($row = mysql_fetch_array($result)){ echo '<div class="gal"><img title="'.$row["name"].'" src="'.$row["src"].'"></div>'; } mysql_free_result($result); ?> i know all i have to do is echo the details of the function, <script type="text/javascript"> <!-- function myPopup() { window.open( "http://www.google.com/", "myWindow", "status = 1, height = 300, width = 300, resizable = 0" ) } //--> </script> and then just add this to the image, onClick="myPopup()", but how can i get the url, "http://www.google.com", to change to the image i want opened? Link to comment https://forums.phpfreaks.com/topic/65344-solved-phpjavascript-pop-up-window/ Share on other sites More sharing options...
plutomed Posted August 17, 2007 Share Posted August 17, 2007 easiest way is to make the image into a link and put the target attribute to _blank Link to comment https://forums.phpfreaks.com/topic/65344-solved-phpjavascript-pop-up-window/#findComment-326318 Share on other sites More sharing options...
corillo181 Posted August 17, 2007 Share Posted August 17, 2007 why dont you just ad it to the picture link? <a onclick="window.open('yourlink','yourwindow','balh blah blah')" href="#"><img /><a> Link to comment https://forums.phpfreaks.com/topic/65344-solved-phpjavascript-pop-up-window/#findComment-326322 Share on other sites More sharing options...
Northern Flame Posted August 17, 2007 Author Share Posted August 17, 2007 oh haha alright, i dont know javascript and thats the way i found it on a tutorial, i didnt know you could do it like that, thanks Link to comment https://forums.phpfreaks.com/topic/65344-solved-phpjavascript-pop-up-window/#findComment-326323 Share on other sites More sharing options...
jlp09550 Posted August 17, 2007 Share Posted August 17, 2007 Why using a function? This is something I used which is what you may be looking for: <a href='#' onClick='window.open("smilies.php", "smileys", "resize=0, toolbar=0, menubar=0, resizeable=0, width=250, height=500");'>Smilies</a> Here's one for an image you would have at the end of your coding: echo '<div id="gallery"> while($row = mysql_fetch_array($result)){ echo '<div class="gal"><img title="'.$row["name"].'" src="'.$row["src"].'" onClick=\'window.open("FILENAME", "image_preview", "resize=0, toolbar=0, menubar=0, resizeable=0, width=250, height=500");\'></div>'; } You should customize it, but yeah. Link to comment https://forums.phpfreaks.com/topic/65344-solved-phpjavascript-pop-up-window/#findComment-326324 Share on other sites More sharing options...
Northern Flame Posted August 17, 2007 Author Share Posted August 17, 2007 thanks Link to comment https://forums.phpfreaks.com/topic/65344-solved-phpjavascript-pop-up-window/#findComment-326326 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.