View Single Post
  #1 (permalink)  
Old 08-24-03, 09:57 PM
alfreds's Avatar
alfreds alfreds is offline
Newbie Coder
 
Join Date: Jun 2003
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Wink Variable passing between functions

Hi,

I have a little trouble with passing an array variable (say $file_names) from one function to another. Lets look in more details:

I have following funcitons:
- get_thumbs - to get the list of images in specific directory
- display_thumbs - to display them in ordered way
- display_large - to display larger image selected by user

During get_thumbs function goes through a specified directory and writes all filenames of images in an array.

The end of the get_thumbs states : return($file_names)
And the definition of function display_thumbs is following:

function display_thumbs ($file_names) {

Then, this functions displays all of the thumbnails, generate a link of a larger image for each of it, by awarding an id that corresponds to its place in array.

Afterwards, when user clicks on image, the display_large function is called, and the same array ($file_names) is passed along. BUT, the display_large function does not recieve it! At the same time, the id variable is passed!

Here is the way, the functions are called, basing on URL action variable:

PHP Code:

switch($_GET['action']) {

    
    case 
'thumbs':
        
get_thumbs();
        
display_thumbs($file_names);
    break;
    
    case 
'large':
       
display_large($file_names$_GET['id']);
    break;
    
     default:
       
select_gallery($db);

As i guess, than there might be something wrong with the break operations after each case.

I hope that my explanation is clear enough to get the idea. I would really appreciate your help, as i do not need any code sample, but rather an idea of what might be wrong!

Kaspars

Last edited by alfreds; 08-25-03 at 03:18 AM.
Reply With Quote