Page 1 of 1

New to PHP, need info

Posted: Thu Jan 20, 2005 9:59 am
by OsiViper
ok, im new to php coding, im trying to figure out if there is a way to carry a variable from one page and have it show in the next.

For example, i have one page that is used just to display pictures, i use it as a popup window, and on the previous page i have a Gallery, is there any way to have a variable that carry's into the page its opening from the page that opened it, so i dont have to have a seperate page for each picture, so that i can just put something in so when it clicks on the link it opens the window and opens the picture i clicked on.
(If that makes any sense)

Thanks

Posted: Thu Jan 20, 2005 10:04 am
by feyd
you can pass information through the url of the popup script.. like

your_script.php?id=987123423478

then use $_GET to retrieve the passed information. In this example: $_GET['id'] would equal '987123423478'

Posted: Thu Jan 20, 2005 10:38 am
by OsiViper
now how would i get that to work with <img src="">

Posted: Thu Jan 20, 2005 10:41 am
by feyd
that depends on how you stored the image.. if it's inside the database, then you need to point it to a downloader type script; search for "+force +download"

if you stored the filename/path of the image, then you can use php to place that accessible path as the src url. If you want to keep the path to the file "secret", then use a downloader script as found by the above stuffs.

Posted: Thu Jan 20, 2005 10:44 am
by OsiViper
its as a file, i really dont care about keeping it a seceret

Posted: Thu Jan 20, 2005 11:21 am
by OsiViper
grr i cant figure it out lol. (I just started using PHP Yesterday)

Code: Select all

<?PHP 
echo "<img src="pictures"'.$_GET['id].'".jpg"' width="754" height="570">";
?>

Posted: Thu Jan 20, 2005 11:32 am
by feyd
since the actual filepath is stored in the database, you'll need to fetch it using the id passed.