Jump to content

Quick question


Maverickb7

Recommended Posts

Alright I've been looking for a way to get this done for some time and haven't had any lucky just yet. I post articles to my site every day and when posting a article a specific if I should include one of my image galleries within it. I specify the folder name for the gallery and then use that to list the gallery at the end of the article. Here is where I have a problem. Lets say I have a gallery in the folder "Narnia Screenshots" and within that folder I have another folder called "thumbs". The folder "thumbs" includes the thumbnails of each image.

What I want to know is how I would have my code look in X directory and display the filename of the first file within that folder. Anyone know how I would do this?

I've been seeing a lot of scandir should that be what I should research?
Link to comment
Share on other sites

[!--quoteo(post=367557:date=Apr 23 2006, 01:33 AM:name=Maverickb7)--][div class=\'quotetop\']QUOTE(Maverickb7 @ Apr 23 2006, 01:33 AM) [snapback]367557[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I've been seeing a lot of scandir should that be what I should research?
[/quote]

Either that or readdir()
Link to comment
Share on other sites

Alright, I've seem to have things working fine but I have one problem. Lets say I have 10 articles displayed on my websites front page. I have one bit of code that is being looped to display each article. Now somewhere along the line the it gets confused and displays info that should be for another article. Now after reviewing the code its safe to say that its because the variables are named the same for all articles causing the code to get confused. What I want to know is how I can make each variable unique? Each article has a unique ID so I was thinking that I could just name the variable whatever and put the ID at the end... but I don't know how to do that.

So I guess when it comes down to it what I want to know is how I would give a variable a name... but have that name include a variable? Anyone?
Link to comment
Share on other sites

Alright, I'm using the below code.

[code]$dh  = opendir("/home/public_html/media/");

while (false !== ($filename = readdir($dh))) {
   ${$id}[] = $filename;
}

sort(${$id});
rsort(${$id});
echo ${$id}[0];
}[/code]

I'm using it to generate the filename of the first file within the media folder. Within my media folder is a folder called thumbs and for some reason its listing the folder name rather then the first file. Does anyone know how I can avoid this?
Link to comment
Share on other sites

[!--quoteo(post=367579:date=Apr 22 2006, 10:11 PM:name=Maverickb7)--][div class=\'quotetop\']QUOTE(Maverickb7 @ Apr 22 2006, 10:11 PM) [snapback]367579[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Alright, I'm using the below code.

[code]$dh  = opendir("/home/public_html/media/");

while (false !== ($filename = readdir($dh))) {
   ${$id}[] = $filename;
}

sort(${$id});
rsort(${$id});
echo ${$id}[0];
}[/code]

I'm using it to generate the filename of the first file within the media folder. Within my media folder is a folder called thumbs and for some reason its listing the folder name rather then the first file. Does anyone know how I can avoid this?
[/quote]
I've fixed it by adding:

[code]if ($filename != "." && $filename != ".." && $filename != "s") { ${$id}[] = $filename; }[/code]

works great now!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.