Forum Moderators: coopster

Message Too Old, No Replies

How to split up dynamic results in multiple pages?

navigation,split,results,echo

         

closer

12:01 am on Apr 24, 2003 (gmt 0)

10+ Year Member



Hi,

Before posting this message I have read about 200 pages with information but I am stuck, so I thought to ask the pro guys around if they had any solution to my problem.

Current situation:

I have a website with 10000+ pictures divided in 5 categories.
Each category has 1 page which uses echo to show all images in a specific directory.
Ofcourse, all images are being displayed on 1 page :( now I have over 400 images on 1 page and that eats my bandwith... O, I am not using a database!

What do I want then:
I want the current situation kept, but with maximum 20 images per page and a <previous 1/2/3...next> navigation bar.

Here is the code I use:

function stats() {
global $titulo,$titulo2,$titulo3,$cstats2,$imagen,$bytes,$fotos,$filas,$cnombres1,$dir,$dir2,$dir3,$dir4;
$kb = number_format($bytes/1024);
echo "<table cellspacing=0 cellpadding=4 width=100%>";
echo "<tr><td align=center width=100% bgcolor=$cstats2 class=titulo>$titulo</td></tr>";
echo "<table width=100% cellpadding=2 cellspacing=2><tr>";
$trow = 1;

array_multisort($fotos["modi"],SORT_DESC,$fotos["nombre"]);
reset($fotos);
while (list($key) = each($fotos["nombre"])) {
echo "<td class=nombre align=center bgcolor=$cnombres1 onmouseover=\"mOver(this);return true\" onmouseout=\"mOut(this);return true\" onclick=\"mClick(this);\"><a href=\"javascript:showFotoset('".$dir2.substr($fotos["nombre"][$key],0,-4).$dir4."')\"><img height=200 src=".$dir.$fotos["nombre"][$key]." border=1></a></td>";
if ($trow >= $filas) { echo "</tr><tr>"; $trow=1; } else { $trow++; }
}
echo "</tr>";

echo "</table></table>";
echo "<table><tr ><td align=center width=100% bgcolor=$cstats2 class=titulo><font face=Verdana, Arial, Helvetica, sans-serif size=2>$titulo2</font></td></tr></table>";
}

where $dir is the variable i've used to point to the image directory.

Anyone who could help me with a working version?

jatar_k

4:30 am on Apr 30, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld closer,

I am very sorry that no one has responded before this. The only excuse I have is that with the whole conference in Boston I have had a very hard time getting enough time online.

What about using a counter to count out 20 images? Then when you echo your link to the next page you could have a var like start=21 and then have a while loop that says something like

if ($counter < $start) continue;

unless you have already figured this out with out any help.

closer

2:56 pm on May 1, 2003 (gmt 0)

10+ Year Member



No problem,

I had found an alternate script which does exactly what I wanted, but ...:)

the script i've posted above was a fine and very quick script. I have to admit that my php knowledge is very basic and someone else wrote it (found it on a scriptsite)

The thing is, I understand exactly what you mean, but I cannot find out where he makes the count of the number of pics, i see the array...

well, if you could help me adjusting the script with an example, I would appreciate it!