Jump to content

list directory,(list in pages)[MILLION CENTS QUESTION]


ted_chou12

Recommended Posts

below is the list directory code, but how should i list them in pages?
for example, i want to have ten text files listed on one page, and the next ten on the second page,
tell me if it is going to be too complicated, then i will forget about it
thankyou :D

Edited: oh yeah, if possible, is it possible to list the file in terms of their last modification time, eg. latest goes first

thanks again
[code]
<table bgcolor="#FAEBD7" width="100%">
<tr bgcolor="#D2B48C" align=center width="100%"><td align=center><font face="arial" size=4><b>ID</b></td><td align=center width=30><font face="arial" size=4><b>Thread Con.</b></td><td align=center width="40%"><font face="arial" size=4><b>Thread Name</b></font></td><td align=center width=30><font face="arial" size=4><b>Views</b></font></td><td align=center width=30><font face="arial" size=4><b>Replies</b></font></td><td align=center width="20%"><font face="arial" size=4><b>Thread Strarted By</b></font></td><td align=center width="30%"><font face="arial" size=4><b>Thread Started On</b></font></td><td align=center width="20%"><font face="arial" size=4><b>Last Commented</b></font></td></tr>
<?php
$namearray = array("forum"); // File names you want to exclude
$extarray = array("xml","jpg","php","css","bmp","png","html");  //extension you want to exclude
$files = array();
if ($handle = opendir(".")) {
   while (false !== ($file = readdir($handle))) {
     if($file != "." && $file != ".."){
       if (filetype($file) == "file" || filetype($file) == "dir"){
       $filearray = explode(".", $file);
       $files[$filearray[0]] = $filearray[1];
       }
     }
   }
closedir($handle);
}

foreach($files as $name => $ext){
  if(in_array($name, $namearray, false) || in_array($ext, $extarray, false)){
  } else {
foreach(@file("$name.txt") as $v){list($topic,$category,$number,$datetime,$name,$username,$message,$threadicon) = explode("#",$v);}
  $counteraa = file_get_contents("topic$number-counter.php");
  if (!file_exists("topic$number-counter.php")){$counteraa = 0;}
  $repliesaa = file_get_contents("topic$number-replies.php");
  if (!file_exists("topic$number-replies.php")){$repliesaa = 0;}
  $lastposteraa = file_get_contents("topic$number-lastposter.php");
  if (!file_exists("topic$number-lastposter.php")){$lastposteraa = $name;}
  echo "<tr><td valign=center align=center bgcolor=\"#FFDEAD\">$number</td><td valign=center align=center><img src=\"../smilies/$threadicon.gif\"></td><td align=left valign=center bgcolor=\"#FFDEAD\"><a href=\"../viewtopic.php?id=$category/topic$number\"><font color=\"#A0522D\"><b>$topic</b></font></a></td><td align=center>$counteraa</td><td align=center>$repliesaa</td><td align=center bgcolor=\"#FFDEAD\">$name</td><td align=center>$datetime</td><td align=center bgcolor=\"#FFDEAD\">$lastposteraa</td></tr>"."\n";}
}
?>
</table>
[/code]
Link to comment
Share on other sites

I've always used this to list 10 items on a page
[code]
$limitPerPage = 10;
$initStartLimit = 0;
if (!isset($startLimit))
{
    $startLimit = $initStartLimit;
}
$querylimit = " limit $startLimit,$limitPerPage ";

$nextStartLimit = $startLimit + $limitPerPage;
$previousStartLimit = $startLimit - $limitPerPage;

[/code]
Link to comment
Share on other sites

[quote author=timmah1 link=topic=118766.msg485585#msg485585 date=1166207212]
I've always used this to list 10 items on a page
[code]
$limitPerPage = 10;
$initStartLimit = 0;
if (!isset($startLimit))
{
    $startLimit = $initStartLimit;
}
$querylimit = " limit $startLimit,$limitPerPage ";

$nextStartLimit = $startLimit + $limitPerPage;
$previousStartLimit = $startLimit - $limitPerPage;

[/code]
[/quote]
can anyone explain to me how the code above works?
thankyou.
Link to comment
Share on other sites

Sorry, didn't see  your post earlier

[code]
$limitPerPage = 10;
$initStartLimit = 0;
if (!isset($startLimit))
{
    $startLimit = $initStartLimit;
}
$querylimit = " limit $startLimit,$limitPerPage ";

$nextStartLimit = $startLimit + $limitPerPage;
$previousStartLimit = $startLimit - $limitPerPage;

$bareQuery = "select * photos  $table";
$queryall = $bareQuery.$sorted.$querylimit;
$resultall = MYSQL_QUERY($queryall);
if ($numberall==0) {
    echo "No Records Found !";
}
else if ($numberall>0) {
$x=0;
?>
<a href="<? echo $PHP_SELF; ?>?sortby=id&startLimit=<? echo $startLimit; ?>&limitPerPage=<? echo $limitPerPage; ?>">ID</a>
[/code]

Link to comment
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.