pull values from database and populate popup using php and javascript

J

jsd219

Hi all, I know this is an elementary question but I am at a loss. I
have googled and searched but can not find the answer. My knowledge of
javascript is infant at best. I have a database driven site coded in
php, on the 'display_trip.php' page the user sees a list of possible
trips and with dates. I would like to code it so when the user clicks
on one of the trips a popup window opens with the value stored in the
content field of the database for that particular trip. I have figured
out how to create a popup window for images but not how to pass info
from a query.

below are snippits of my code:

File Name: display_trip.php
------------------------------------------------------------------------------------------------------------
as you can see I am calling the content field in my query.

$query = "SELECT TRIP_ID, TRIP_TITLE, TRIP_THUMB, TRIP_CONTENT
FROM TRIPS
WHERE TRIP_ID != ''";
------------------------------------------------------------------------------------------------------------
$chref = "<a class=triplink href=\"javascript:OpenEvent('";
-----------------------------------------------------------------------------------------------------------
here is part of my echo statement to create the link:

"<td align=\"left\">" . "&nbsp;&nbsp;" . "{$chref}{$row['TRIP_ID']}')
\">" . "{$row['TRIP_TITLE']} " . "</td>" .
------------------------------------------------------------------------------------------------------------


File Name: header.php file
------------------------------------------------------------------------------------------------------------
here is my javascript function from my header.php

function OpenEvent(id)
{
window.open ('SOMETHING NEED TO GO HERE' + id, 'newwindow',
config='height=450, width=550, toolbar=no, menubar=no, scrollbars=no,
resizable=no, location=no, directories=no, status=no')
}
 
P

Peter Michaux

Hi all, I know this is an elementary question but I am at a loss. I
have googled and searched but can not find the answer. My knowledge of
javascript is infant at best. I have a database driven site coded in
php, on the 'display_trip.php' page the user sees a list of possible
trips and with dates. I would like to code it so when the user clicks
on one of the trips a popup window opens with the value stored in the
content field of the database for that particular trip. I have figured
out how to create a popup window for images but not how to pass info
from a query.

below are snippits of my code:

File Name: display_trip.php
------------------------------------------------------------------------------------------------------------
as you can see I am calling the content field in my query.

$query = "SELECT TRIP_ID, TRIP_TITLE, TRIP_THUMB, TRIP_CONTENT
FROM TRIPS
WHERE TRIP_ID != ''";
------------------------------------------------------------------------------------------------------------
$chref = "<a class=triplink href=\"javascript:OpenEvent('";
-----------------------------------------------------------------------------------------------------------
here is part of my echo statement to create the link:

"<td align=\"left\">" . "&nbsp;&nbsp;" . "{$chref}{$row['TRIP_ID']}')
\">" . "{$row['TRIP_TITLE']} " . "</td>" .
------------------------------------------------------------------------------------------------------------

File Name: header.php file
------------------------------------------------------------------------------------------------------------
here is my javascript function from my header.php

function OpenEvent(id)
{
window.open ('SOMETHING NEED TO GO HERE' + id, 'newwindow',
config='height=450, width=550, toolbar=no, menubar=no, scrollbars=no,
resizable=no, location=no, directories=no, status=no')
}

I'm guessing you want 'SOMETHING NEED TO GO HERE' to be something like
'/path/to/script.php?TRIP_ID='

the '+ id' will then complete the query string (ie the part of the URL
after the question mark.)


Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top