showing all pages on a folder on index file.

08-10-06, 03:31 AM
|
|
Newbie Coder
|
|
Join Date: Apr 2006
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
showing all pages on a folder on index file.
I have a folder, in that folder there are many pages, for example , page1.php,page2.php , pag3.php .. and i want to keep adding pages in that folder later.Now i want to display the names of all the pages which are in that folder but without extension.. for example, i want to display.like
archive:
page1 (Not page1.php)
page2
page3
and i want that it adds all the pages available in that folder, even which i will add later.
please help me regarding to this.
Thanks
|

08-10-06, 03:39 AM
|
 |
Community Leader
|
|
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
|
|
Untested but should work.
|

08-10-06, 04:05 AM
|
|
Newbie Coder
|
|
Join Date: Apr 2006
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
oh great, thank you very much nico_swd.. will it sort files by name ?
okay i have one more question please.for example i have 20 files in my folder..and it will display all files in one column.
i want to display each 10 files in one column, how can i print column .
for example.
i want to display like
1 11
2 12
3 13
4 ..
5
6
7
8
9
10
|

08-10-06, 07:05 AM
|
 |
Coding Addict
|
|
Join Date: Jul 2006
Location: Scotland
Posts: 302
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Nico's code modified to allow alpha sorting
|

08-10-06, 07:25 AM
|
|
Newbie Coder
|
|
Join Date: Apr 2006
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
thanks, but it shows the output in one column..i want to show the X number of items in one column.. how can i create output in multi columns please?
|

08-10-06, 08:03 AM
|
|
Aspiring Coder
|
|
Join Date: Jan 2006
Posts: 506
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
|
Originally Posted by itssami
thanks, but it shows the output in one column..i want to show the X number of items in one column.. how can i create output in multi columns please?
|
You will need to have 2 loops one nested within the other.
|

08-10-06, 08:14 AM
|
 |
Community Liaison
|
|
Join Date: Feb 2004
Posts: 1,232
Thanks: 1
Thanked 11 Times in 11 Posts
|
|
Assuming you only want to grab .php files:
No need for multiple loops. 
__________________
The toxic ZCE
Last edited by Keith; 08-10-06 at 08:28 AM.
|

08-10-06, 08:52 AM
|
 |
Community VIP
|
|
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Here is a way which forms the columns with 10 rows per column -
In addition to the code added to form the columns, this has two differences from the original code - it only lists files (it does not lists folder names within the folder) and it uses a natural sort (where file1.php, file10.php, file2.php are listed in the proper order file1.php, file2.php file10.php)
Edit: This also correctly orders upper and lowercase file names. With a case sensitive sort and the glob(...) function Page1.php (starts with uppercase) will appear before anything.php (starts with lowercase)
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
Last edited by mab; 08-10-06 at 09:00 AM.
|

08-10-06, 09:24 AM
|
 |
Community Leader
|
|
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
|
|
A little fix on Mab's code.
This:
Should be
|

08-10-06, 09:35 AM
|
 |
Community VIP
|
|
Join Date: Oct 2005
Location: Denver, Co. USA
Posts: 2,674
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks (I tested this in the same folder with the script and did not catch this for a different folder path.)
__________________
Error checking, error reporting, and error recovery. If your code does not have these to get it to tell you why it is not working, what makes you think someone in a programming forum will be able to tell you why it is not working???
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|