Creating pages dependant on number of files in DIR (NONE SQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Abz
Forum Newbie
Posts: 6
Joined: Sat Nov 27, 2004 8:09 pm
Location: London, UK

Creating pages dependant on number of files in DIR (NONE SQL

Post by Abz »

hello,

iv already posted a problem afew posts away, and iv got that issue resolved, am wondering how could i make this script display the other fileds on another page, i can see how it is possible if you use SQL, however this script does NOT use SQL, its mearly a utility that displays the content on a directory, and combines the relitive txt file to its avi file and lists it as a table.

Code: Select all

<?PhP  
#THIS IS THE CODE, DON'T MESS! 

$handle=opendir(".");  
while (($file = readdir($handle))!=false){  
rtrim($file);  
if($file=="*.*"){  
$file=readdir($handle);  
$file=readdir($handle);  
}  
if($file=="hits.txt"){  
$file=readdir($handle);  
}  
if(eregi("[a-zA-Z0-p_-]*.txt",$file)!=false){  
$spliter=explode(".",$file);  
$filea="$spliter[0].avi";  
$filei="TEXT INFO";  
$filez="$spliter[0].avi";  
$size=filesize($filez);  
$size=($size/1024);  
$size=round($size,1);  
$info="  Text info files have not yet been created..";  
echo "<TABLE WIDTH=100% BORDER=0 CELLSPACING=0 CELLPADDING=0 CLASS=TABLEMAIN><TR>";  
echo "<TD CLASS=TDTOP colspan=1><IMG SRC="3dsmax/mov/blank.gif" width=1 height=20></TD>";  
echo "<TD CLASS=TDFILESIZE WIDTH=30%></TD></TR>";  
echo "<TR><TD CLASS=TDTITLECONTENT>";  
echo "<img src="hiddin/box.gif"><IMG SRC="3dsmax/mov/blank.gif" width=5 height=1><A HREF="" onClick="window.  open('$filea','cal','width=600,height=400,status=n

  o,scrollbars=yes,resizable=yes,toolbar=no,location

=no,directories=no');return false">$spliter[0]</A></B></TD><TD CLASS=TDFILESIZE>Size: $size Kb";  
echo "</TD></TR>";  
echo "<TR><TD colspan=2 width=100% CLASS=TDCONTENT>";  
$filer="$file";  
$file=file($filer);  
$sline=0;  
$count=count($file);  
$eline=$count;  
$i = $count;  
for($j=$sline;$j<$eline;$j++){  
echo "$file[$j]";  
}  
echo "</TD></TR>";  
echo "<TR CLASS=TDBOT>";  
echo "<TD CLASS=TDBOT>";  
echo "<IMG SRC="3dsmax/mov/blank.gif" width=1 height=20>";  
echo "<TD CLASS=TDDOWNLOAD><A HREF="" onClick="window.  open('$filea','cal','width=600,height=400,status=n

  o,scrollbars=yes,resizable=yes,toolbar=no,location

=no,directories=no');return false">[] PLAY</A></TD>";   
echo "</TD></TR></TABLE>";  

} else {  

}  

}  
?>

//
the script as you might or might not know, displays the content of a directory, if i have a large amout of files in that directory then am sure you relise how big the page would become,

so like after the script displays 10 fields it gives it displays a total of pages and current page, etc...

//



Sorry if im asking to many questions, or being a pain, am just trying to solve this and then i think the script will be perfect, well almost.

Abs

http://www.3dnuta.com
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

When you printing out the names of the files simply place it in a loop to tell it to only print if $x > 10 AND $x < 20 etc, and then increment $x each time you try to print out a file.
Abz
Forum Newbie
Posts: 6
Joined: Sat Nov 27, 2004 8:09 pm
Location: London, UK

thank you

Post by Abz »

thanks for that dude,

is there a chance you might show me how the script might look like after doing so, cos am not very good with php or coding in general, am really sorry.

if you cant then dont worry about thanks for the help anyway.
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

Ummm something like:

Code: Select all

...
...
$count=count($file);  
$eline=$count;  
$i = $count;  
for($x=0, $j=$sline;$j<$eline;$x++, $j++){  
   if($x>$start AND $x<$end){
      echo "$file[$j]";  
   }
}  
Where $start is where you want the files to be printed from, and $end is the last file.
Post Reply