| | |
PHP Variables
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
When the user clicks on the link they are doing it on the "client" so you need something like javascript.
To save the value you can use sessions or cookies.
Rather than us giving you examples, maybe you'd like to tell us what the problem is that you're trying to solve!
To save the value you can use sessions or cookies.
Rather than us giving you examples, maybe you'd like to tell us what the problem is that you're trying to solve!
•
•
Join Date: Oct 2005
Posts: 35
Reputation:
Solved Threads: 1
well you see, i have links to different images. the images are categorized in folders of 20. so everytime when a user clicks on a link, i would like the variable $folder to be set to the folder name where that kind of images exist. the $folder will then be passed onto another php page where it will load all 20 images from the folder. so overall the second php page never changes, and so i don't have to creat a different page for every folder....
oh, ok
You can set your links up to be
and then in display.php
[php]<?php
$folder = (isset($_GET['folder']))?$_GET['folder']:'';
//echo getcwd();
//$folder = "../../../Apache Group/Apache/htdocs/gallery/images/";
$dh = opendir($folder);
while (false !== ($filename = readdir($dh))) {
$extbits = explode('.', strrev($filename));
if (in_array( strtolower( strrev($extbits[0])), array('jpg','gif','png')))
{
$files[] = $filename;
}
}
sort($files);
print_r($files);
?> [/php]
You can set your links up to be
PHP Syntax (Toggle Plain Text)
<a href='display.php?folder=imgs1'>Images 1</a>
and then in display.php
[php]<?php
$folder = (isset($_GET['folder']))?$_GET['folder']:'';
//echo getcwd();
//$folder = "../../../Apache Group/Apache/htdocs/gallery/images/";
$dh = opendir($folder);
while (false !== ($filename = readdir($dh))) {
$extbits = explode('.', strrev($filename));
if (in_array( strtolower( strrev($extbits[0])), array('jpg','gif','png')))
{
$files[] = $filename;
}
}
sort($files);
print_r($files);
?> [/php]
![]() |
Similar Threads
- Can a text link pass php variables? (PHP)
- PHP Variables (PHP)
- help with php and javascript (PHP)
- PHP Downloads:Which one should I choose? *Newbie* (PHP)
- Using Search Engine Friendly PHP URLs (PHP)
Other Threads in the PHP Forum
- Previous Thread: PHP Screen Scraping
- Next Thread: Click Ads First..!!
| Thread Tools | Search this Thread |
apache api array beginner binary body broken buttons cakephp checkbox class cms code cron curl database date date/time display dynamic ebooks echo email error file files folder form forms function functions global google href htaccess html image include insert ip javascript joomla limit link list login mail mediawiki menu mlm msqli_multi_query multiple mycodeisbad mysql number oop parameter paypal pdf php phpincludeissue problem query radio random recourse recursion regex remote script search seo server sessions sms source sp space speed sql static subdomain syntax system table tag tutorial update upload url validator variable vbulletin video web webdesign white wordpress xml youtube





