Current location: Hot Scripts Forums » Programming Languages » PHP » please help to paginate index of listing


please help to paginate index of listing

Reply
  #1 (permalink)  
Old 12-27-03, 08:35 PM
sona sona is offline
New Member
 
Join Date: Jul 2003
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
please help to paginate index of listing

Consider this :
I have got a folder which contains various .dat files
I want index or listing pages which enlists the files ( alpha-sorted)
but instead of a very long list ( when there are too many files ) which people has to scroll I want to break it up into pages like
< prev page | 1 | next page > or something like this

I have seen various paginate functions but am unable to integrate in the following script - so an exact code help will be very very much appreciated.

the folder name: myfiles
========================
contains files like abba.dat, babba.dat, cabba.dat etc etc etc

the indexing scipt : indi.php
=============================
PHP Code:

<?


function index() {
global 
$this_dir$PHP_SELF;
$this_dir opendir(myfiles);
$files = array();
while (
false !== ($file readdir($this_dir))) {
if (
$file != "." && $file != "..") {
$kobitaa str_replace (".dat""""$file");
$kobitaa str_replace ("_"" ""$kobitaa");
$extension array_pop(explode("."$file));
if(
$extension == "dat") {
array_push($files$kobitaa);
}
}
}
natcasesort($files);


$tpp '12'
$offset = (isset($_GET['offset'])) ? $_GET['offset'] : '0'
$limit $tpp $offset;
 

$t 0// Setup for multi pages
foreach ($files as $kobitaa) { // Sorta like while(row = mysql_fetch_array())
$file str_replace(" ""_"$kobitaa);
$file $file ".dat";
$t++;

if (
$t $offset && $t <= $limit) {
echo 
"$kobitaa<br>\n";
}
}
echo 
"<br><font size=2>want to insert here link to multiple pages<font>\n";

}

switch(
$view) {
default:
index();
break;
}
  
?>
the paginate functions
=======================
which I have tried to take help [author m0bster :nextpage function]

http://www.evilwalrus.com/code_comments.php?codeEx=624

mobster suggests this : include the function and this code

$multi = NextPage($tpp, $offset, $t); // topics per page, the offset, and number of topics total

However I am awfully unable ... any help will be received with great gratitude
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How much time does it take to add a new listing to the resource index? parmeet General HotScripts Site Discussion 2 12-16-03 12:50 AM
Update listing NFec HotScripts Site Bug Reports 0 09-20-03 05:31 AM
How do I change my own listing? aleborg Hot Scripts Forum Questions, Suggestions and Feedback 3 08-26-03 09:35 AM
Add a listing error? MadDog HotScripts Site Bug Reports 2 08-05-03 11:52 AM
Updating a listing and getting rated... amailer Hot Scripts Forum Questions, Suggestions and Feedback 2 06-09-03 09:50 PM


All times are GMT -5. The time now is 07:45 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.