Welcome to Dream.In.Code
Getting Help is Easy!

Join 118,877 Programmers for FREE! Ask your question and get quick answers from experts. There are 1,957 online right now! We've got more than 500 tutorials and 2,000 snippets. Join and find out why Dream.In.Code is the #1 programming help community on the internet! Registration is fast and FREE... Join Now!



Help, how to create a popup? Need fast help.

 
Reply to this topicStart new topic

Help, how to create a popup? Need fast help.

Dancia
post 19 Jun, 2008 - 12:47 PM
Post #1


D.I.C Head

**
Joined: 15 Jun, 2008
Posts: 57



Thanked 1 times
My Contributions


Ok I have written such code:
CODE

while($row = mysql_fetch_array($result1)) {
    echo '
    <table cellspacing="0" cellpadding="0" border="1" width="100%">
    <tr><td>Kategorija: '.$row[1].'</td></tr>
    ';
    $result2 = mysql_query("SELECT * FROM prekes WHERE id_cat='$row[0]'") or die(mysql_error());
    while($rows = mysql_fetch_array($result2)) {
        echo '
            <tr><td><center><a href="#" onClick=""><img src="'.$rows[4].'"></a></center></td></tr>
            <tr><td><center>'.$rows[2].'</center></td></tr>
        ';
    }
    echo '
    </table>';
}



Problem is here:
CODE

<tr><td><center><a href="#" onClick=""><img src="'.$rows[4].'"></a></center></td></tr>

I want to make a popup in the center of window in which I would put variables $rows[5] (image) and $rows[3] (description of image). But I don't know how to do this. Im really lame in javascript. Searched for this in google, but still have no idea how to transver PHP variables there...

This post has been edited by Dancia: 19 Jun, 2008 - 12:47 PM
User is offlineProfile CardPM

Go to the top of the page


BetaWar
post 19 Jun, 2008 - 02:35 PM
Post #2


#include <soul.h>

Group Icon
Joined: 7 Sep, 2006
Posts: 1,692



Thanked 64 times

Dream Kudos: 1075
My Contributions


What I would suggest is going about this with creating a popup window that uses $_GET variables to load the content dynamically verses telling it what to load when you make the window.

This can be done like so:

CODE
var newwindow;
function popup(immge)
{
                url = "http://www.example.com/index.php?view="+image;
    newwindow=window.open(url,'name','height=400,width=200');
    if (window.focus) {newwindow.focus()}
}


Where url is what is being opened, name is the window title, and width/height are self explanitory.

Now, what I would do is something like so for the image popup:

CODE
<tr><td><center><a href="#" onClick="popup('.$rows[5]).'"><img src="'.$rows[4].'"></a></center></td></tr>


Which would tell it what the main imaeg url is, then you could query for the rest of the information (description) from a database and output it. Either that or you could go about placing both the image url and description in the url (but browsers normally hae a 2k size limit on the url so if it is a long description this may not work (or if ther is html, or line breaks or a number of other things.

Hope that helps.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 10/13/08 02:34AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month