You are here: php paging of an array... « PHP « IT news, forums, messages
php paging of an array...

Posted by oswald on 01/23/06 05:17

i've got an array of 500 filenames (images to be exact).. i need to do
paging of the display... i can figure out how to do this with mysql, but
this i can't

here's the piece of code displaying all images on one page.. resize.php
does thumbnails on the fly.... i need those results to be 50 by page an
so on... maybe anyone can help?

$dirlist = "./";

//main
$playername=strtoupper($playername);
if ($playername == "")
{
//
-------------------------------------------------------------------------
----------------------------------------------------------------
// if no search entered, display all pictures
//
-------------------------------------------------------------------------
----------------------------------------------------------------
echo "You chose to display all available pictures.<BR><BR><BR>";
if ($alreadydone != 1) {
if (is_dir($dirlist)==true ) {
chdir( $dirlist );
$handle=opendir( ".");
}
$x=0;
$images=array();
while (($file = readdir($handle))!==false) {
$pieces = explode (".", $file);
if ($pieces[0] && $pieces[1]) {
if (($pieces[1]=="gif") || ($pieces[1]=="jpg") || ($pieces[1]=="GIF")
|| ($pieces[1]=="JPG") || ($pieces[1]=="bmp") || ($pieces[1]=="BMP") ||
($pieces[1]=="png") || ($pieces[1]=="PNG")) {
$images[$x]=$file;
$x++;
}
}
}
closedir($handle);
}
else
{
$images = unserialize(base64_decode($myArrayS));
}
// display results

for ($i=0; $i<sizeof($images); $i++)
{

?><a href="showpic.php?p=<? echo $i;?>"
target="imagewindow" onclick="window.open('showpic.php?p=<? echo $images
[$i]; ?>','imagewindow',',toolbar=no,directories=no,status=no,
menubar=no,scrollbars=yes,resizable=yes'); return false;">
<B><? echo "<img src=resize.php?filename=".$images
[$i].">";?>


<? $p_names=explode('_',$images[$i]); echo $p_names[1]."
". $p_names[2].""; ?></a>

<?
if (($i+1) % 8 == 0)
echo"<br>";

}


}
// end if display all pictures



--
oswald

gg: 7777 | I deny the current reality and substitute it with my own.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация