PHP Variables

Reply

Join Date: Oct 2005
Posts: 35
Reputation: Xtothel is an unknown quantity at this point 
Solved Threads: 1
Xtothel Xtothel is offline Offline
Light Poster

PHP Variables

 
1
  #1
Oct 28th, 2005
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
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 138
Reputation: sarahk is an unknown quantity at this point 
Solved Threads: 1
sarahk's Avatar
sarahk sarahk is offline Offline
Junior Poster

Re: PHP Variables

 
0
  #2
Oct 29th, 2005
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!
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 35
Reputation: Xtothel is an unknown quantity at this point 
Solved Threads: 1
Xtothel Xtothel is offline Offline
Light Poster

Re: PHP Variables

 
0
  #3
Oct 29th, 2005
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....
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 138
Reputation: sarahk is an unknown quantity at this point 
Solved Threads: 1
sarahk's Avatar
sarahk sarahk is offline Offline
Junior Poster

Re: PHP Variables

 
0
  #4
Oct 29th, 2005
oh, ok

You can set your links up to be

  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]
Reply With Quote Quick reply to this message  
Join Date: Oct 2005
Posts: 35
Reputation: Xtothel is an unknown quantity at this point 
Solved Threads: 1
Xtothel Xtothel is offline Offline
Light Poster

Re: PHP Variables

 
0
  #5
Oct 31st, 2005
XD thank you!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC