SatanCow Posted May 22, 2006 Share Posted May 22, 2006 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.ThanksAndy Quote Link to comment https://forums.phpfreaks.com/topic/10222-page-count-script/ Share on other sites More sharing options...
AndyB Posted May 23, 2006 Share Posted May 23, 2006 Here's your starter.[code]<?phpforeach (glob("*.jpg") as $filename) { $file[] = $filename; // array of all .jpg file names starting at $file[0]}?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/10222-page-count-script/#findComment-38102 Share on other sites More sharing options...
SatanCow Posted May 23, 2006 Author Share Posted May 23, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/10222-page-count-script/#findComment-38105 Share on other sites More sharing options...
SatanCow Posted May 23, 2006 Author Share Posted May 23, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/10222-page-count-script/#findComment-38109 Share on other sites More sharing options...
SatanCow Posted May 23, 2006 Author Share Posted May 23, 2006 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? Quote Link to comment https://forums.phpfreaks.com/topic/10222-page-count-script/#findComment-38112 Share on other sites More sharing options...
Naimoigiant Posted May 23, 2006 Share Posted May 23, 2006 The FONT tag is deprecated, so you won't be able to use it for much longer. If you want to change the color of text, use the STYLE attribute within a tag with the value "color: #FF0000;" or whatever you prefer. Quote Link to comment https://forums.phpfreaks.com/topic/10222-page-count-script/#findComment-38114 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.