ted_chou12 Posted December 15, 2006 Share Posted December 15, 2006 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 itthankyou :DEdited: oh yeah, if possible, is it possible to list the file in terms of their last modification time, eg. latest goes firstthanks 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 https://forums.phpfreaks.com/topic/30780-list-directorylist-in-pagesmillion-cents-question/ Share on other sites More sharing options...
timmah1 Posted December 15, 2006 Share Posted December 15, 2006 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 https://forums.phpfreaks.com/topic/30780-list-directorylist-in-pagesmillion-cents-question/#findComment-141888 Share on other sites More sharing options...
ted_chou12 Posted December 15, 2006 Author Share Posted December 15, 2006 thanks, ill let you know if i have trouble combining them. Link to comment https://forums.phpfreaks.com/topic/30780-list-directorylist-in-pagesmillion-cents-question/#findComment-141890 Share on other sites More sharing options...
ted_chou12 Posted December 15, 2006 Author Share Posted December 15, 2006 timmah, i dont quite understand, can you just explain it briefly to be please? Link to comment https://forums.phpfreaks.com/topic/30780-list-directorylist-in-pagesmillion-cents-question/#findComment-141897 Share on other sites More sharing options...
ted_chou12 Posted December 15, 2006 Author Share Posted December 15, 2006 [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 https://forums.phpfreaks.com/topic/30780-list-directorylist-in-pagesmillion-cents-question/#findComment-141973 Share on other sites More sharing options...
complex05 Posted December 15, 2006 Share Posted December 15, 2006 you need to use it in an SQL querySELECT * FROM table WHERE field='$value' LIMIT $querylimit Link to comment https://forums.phpfreaks.com/topic/30780-list-directorylist-in-pagesmillion-cents-question/#findComment-141979 Share on other sites More sharing options...
timmah1 Posted December 15, 2006 Share Posted December 15, 2006 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 https://forums.phpfreaks.com/topic/30780-list-directorylist-in-pagesmillion-cents-question/#findComment-141983 Share on other sites More sharing options...
ted_chou12 Posted December 15, 2006 Author Share Posted December 15, 2006 sorry, but i am even more confused now. where should i put my list of dir in?Ted :DMany thanks Link to comment https://forums.phpfreaks.com/topic/30780-list-directorylist-in-pagesmillion-cents-question/#findComment-141991 Share on other sites More sharing options...
ted_chou12 Posted December 16, 2006 Author Share Posted December 16, 2006 can anyone suggest me where could i put my dir listing in? Link to comment https://forums.phpfreaks.com/topic/30780-list-directorylist-in-pagesmillion-cents-question/#findComment-142270 Share on other sites More sharing options...
ted_chou12 Posted December 16, 2006 Author Share Posted December 16, 2006 can anyone give me some ideas as to how to put the two together? pelase?thanks :D Link to comment https://forums.phpfreaks.com/topic/30780-list-directorylist-in-pagesmillion-cents-question/#findComment-142319 Share on other sites More sharing options...
ted_chou12 Posted December 16, 2006 Author Share Posted December 16, 2006 as you can see, "echo" is listing my data, how are you suppose to list ten of them in one page? Link to comment https://forums.phpfreaks.com/topic/30780-list-directorylist-in-pagesmillion-cents-question/#findComment-142321 Share on other sites More sharing options...
ted_chou12 Posted December 16, 2006 Author Share Posted December 16, 2006 hey, i see it, i think the code above is only for mysql right?but im not using mysql db, im just listing out the directory, is it possible to modify it in some way so i will able to use it?thanks Ted. Link to comment https://forums.phpfreaks.com/topic/30780-list-directorylist-in-pagesmillion-cents-question/#findComment-142342 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.