Jump to content

Recommended Posts

I'm a total n00b with PHP, I need a script that will count the number of .jpg files in a directory and re turn the number as well as the number of the current .jpg being viewed. I have no idea where to start writing this script. Just need something that will return a value on the page something like [b][ Page 9 of 45 ][/b] where it can dynamicly get the number of the current page and total page from what ever directory it's in.

Any ideas how I can do this? Maybe a starting point for writing this script.

Thanks
Andy
Link to comment
https://forums.phpfreaks.com/topic/10222-page-count-script/
Share on other sites

Ok, for me I need to figure out what each thing is doing. I get that the second part is making an array of the files, what is that first line doing?

And a questions about arrays, is that array the total number of files, or should it be though of more as if there are 12 files the array is just the nmbers 1 through 12?
Link to comment
https://forums.phpfreaks.com/topic/10222-page-count-script/#findComment-38105
Share on other sites

Right on, i have it showing the ammount of files now

[code]foreach (glob("*.jpg") as $filename) {
    $file[] = $filename; // array of all .jpg file names starting at $file[0]
}
$array_count = count($file);
echo "$array_count";[/code]

The last problem is getting it to show me what image it is using out of the total images.
So if it's showing image 5 of 12 how do i get the code to know that were looking at image 5?
Link to comment
https://forums.phpfreaks.com/topic/10222-page-count-script/#findComment-38109
Share on other sites

Ok that's good enough, i'm going to quit while i'm ahead. This would have to somehow interact with the image gallery script. So it's good as it is.

One last thing, in the following code:
[code]echo "<center><strong>Current Folder: $folder Total of $array_count Pages</strong></center>";[/code]

I can't figure out how to change the font color of the $folder, and $array_count so they stick out more, inside the "" I was able to use lots of HTML tags but the one for font color won't work, is this possible? and how?
Link to comment
https://forums.phpfreaks.com/topic/10222-page-count-script/#findComment-38112
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.