944,008 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 2558
  • PHP RSS
Oct 28th, 2005
1

PHP Variables

Expand Post »
hi, i want to give a value to a variable when the surfer clicks on a link, i am not sure how to do that in php, also, i would like to pass on the value of that variable to a different page. can someone help me with the coding? plz? providing samples would be greately appreciated
Similar Threads
Reputation Points: 11
Solved Threads: 1
Light Poster
Xtothel is offline Offline
35 posts
since Oct 2005
Oct 29th, 2005
0

Re: PHP Variables

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!
Reputation Points: 10
Solved Threads: 1
Junior Poster
sarahk is offline Offline
138 posts
since Apr 2005
Oct 29th, 2005
0

Re: PHP Variables

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....
Reputation Points: 11
Solved Threads: 1
Light Poster
Xtothel is offline Offline
35 posts
since Oct 2005
Oct 29th, 2005
0

Re: PHP Variables

oh, ok

You can set your links up to be

PHP Syntax (Toggle Plain Text)
  1. <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]
Reputation Points: 10
Solved Threads: 1
Junior Poster
sarahk is offline Offline
138 posts
since Apr 2005
Oct 31st, 2005
0

Re: PHP Variables

XD thank you!
Reputation Points: 11
Solved Threads: 1
Light Poster
Xtothel is offline Offline
35 posts
since Oct 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: PHP Screen Scraping
Next Thread in PHP Forum Timeline: Click Ads First..!!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC