473,473 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Folder list with Pagination

I'm looing for a simple PHP file list program, that will show all the
files in a folder, but show them in batchs of 10 - 15..

Any ideas??

Many Thanks

Sep 11 '06 #1
4 8699

je***********@yahoo.com wrote:
I'm looing for a simple PHP file list program, that will show all the
files in a folder, but show them in batchs of 10 - 15..

Any ideas??

Many Thanks
This is a little crude but it should get the job done.

<?php
if ($handle = opendir('.')) {
$count = 0;
while (false !== ($file = readdir($handle))) {
echo $count == 0 ? "<ol>" : "";
echo "<li>$file</li>";
$count++;
if($count == 10){
echo "</ol>";
$count = 0;
}
}
echo $count != 10 ? "</ol>" : "";
closedir($handle);
} ?>

Sep 11 '06 #2

je***********@yahoo.com wrote:
I'm looing for a simple PHP file list program, that will show all the
files in a folder, but show them in batchs of 10 - 15..

Any ideas??

Many Thanks
Another solution would be to read the file names into an array and
iterate over that in sets of 10 or 15.

Sep 11 '06 #3

Noodle wrote:
je***********@yahoo.com wrote:
I'm looing for a simple PHP file list program, that will show all the
files in a folder, but show them in batchs of 10 - 15..

Any ideas??

Many Thanks

This is a little crude but it should get the job done.

<?php
if ($handle = opendir('.')) {
$count = 0;
while (false !== ($file = readdir($handle))) {
echo $count == 0 ? "<ol>" : "";
echo "<li>$file</li>";
$count++;
if($count == 10){
echo "</ol>";
$count = 0;
}
}
echo $count != 10 ? "</ol>" : "";
closedir($handle);
} ?>
Hi

Thanks for that..It works, but I didn't describe it properly...

What I should have said that I would like it to use pagination, showing
10 entried per page, then allowing the user to move back or forward
through the pages !

Cheers

Sep 13 '06 #4
In article <11*********************@d34g2000cwd.googlegroups. com>,
je***********@yahoo.com wrote:
Noodle wrote:
je***********@yahoo.com wrote:
I'm looing for a simple PHP file list program, that will show all the
files in a folder, but show them in batchs of 10 - 15..
>
Any ideas??
>
Many Thanks
This is a little crude but it should get the job done.

<?php
if ($handle = opendir('.')) {
$count = 0;
while (false !== ($file = readdir($handle))) {
echo $count == 0 ? "<ol>" : "";
echo "<li>$file</li>";
$count++;
if($count == 10){
echo "</ol>";
$count = 0;
}
}
echo $count != 10 ? "</ol>" : "";
closedir($handle);
} ?>

Hi

Thanks for that..It works, but I didn't describe it properly...

What I should have said that I would like it to use pagination, showing
10 entried per page, then allowing the user to move back or forward
through the pages !

Cheers

#!/usr/bin/php
<?
if (!$_GET["start"]) $_GET["start"] = 1;
$show = 10;

$dir = ".";
$thedir = opendir($dir);
while (false !== ($file = readdir($thedir))){
if (in_array($file, array(".", ".."))) continue;
$files[] = $file;
}
$pages = ceil(count($files)/$show);

foreach ($files as $file){
$nr++;
if ($nr >= $_GET["start"] && $nr < $_GET["start"]+$show){
print "<li$nr. $file\n";
}
}

?>
--
Sandman[.net]
Sep 13 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Sharif T. Karim | last post by:
Anyone know of a up-to-date tutorial for pagination where I can have it like: Prev 1 2 3 4 Next Thanks. -- Sharif T. Karim ....you don't know wrath yet...
1
by: Faree | last post by:
I am workign on a news portal which needs paginaiton as usual.but all the code i got depends on the number of records that will come from database :( .it is working well too. But i need...
1
by: Kruq | last post by:
Is it possible to use pagination with DataList? Can't find it.. :( Kruq
11
by: ste | last post by:
Hi there, Further to my recent posts where I've received excellent help from Rik and Jerry, I've ended up with an image gallery on my website that displays images in a table, 3 images per row. ...
1
by: dhanu | last post by:
How to manage pagination in AJAX? My requirement is similar to GMails inbox feature. Whenever a new mail comes in,the newly arrived mail is at the start of my inbox and last row in that page...
4
by: Ed Jay | last post by:
I generate a DHTML page (a medical report) with dynamically generated text based on user input (answers to questions). The page length changes dynamically. I desire that when the page is printed...
1
by: shalini jain | last post by:
Hi, I want to know how can we do pagination using XSL. There are number of tutorials available on pagination using PHP but nothing with XSL. i am really stuck with my code. Below is the code that...
1
by: cfsuman | last post by:
ColdFusion Tutorial List How to use cfsaveconetnt ? User Login Application code documentation Pagination Pagination : Component based Pagination : Function based Slide Show Color Picker
2
by: kkshansid | last post by:
this is my search page on which i am getting two parameters from previous page but the problem is that as soon as i click any other next pages my sql query fails as it doesnt get these two parameters...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.