...

View Full Version : Which is selected, pagiation ?



Peuplarchie
02-25-2008, 03:37 AM
Good day to you all,
I'm working on a piece of code that i have built and I have a problem with my pagination script which does not tell me which page I'm on,like put is number on bold.

This script is use as a directory listing of images for a photos gallery.
Image listed by 12.


Can someone help me with this.

Here is my code :






<?php

$image_counter = -1;
$row_counter = 0;
$cell_counter = 0;
$i=0;
$show=array('.jpg','.JPG','.gif','.GIF');

$val= $_GET['folder'];
$val1 = $_GET['folder'];
$val0 = $val1;
$val.="/";

$path = "$val";
$path2 = str_replace("Pic-S", "Pic-B", $val);
$dirshort = substr($val,20);
$dirshort0 = $val1;

$comicon = "../Muraille/Change-comment-icon/comment_icon_change.txt";
$fh1 = fopen($comicon, 'r');
$outputt1 = fgets($fh1);
$output1 = str_replace("../..", "../", $outputt1 );
fclose($fh1);



$dir_handle = @opendir($path) or die("Unable to open $path");
$image_table = "\n<tr><td bgcolor=\"#cccccc\" align=\"center\" colspan=\"3\" width=\"100%\"><table valign=\"top\" align=\"center\" width=\"100%\" border=\"0\" cellspacing=\"0\">\n";
while (false !== ($file = readdir($dir_handle))) {
if($file != "." && $file != "..") {
echo"";
}
if(in_array(substr($file,-4,4),$show)){
if(!(($image_counter + 1) % 3)){
$row_counter++;
}


$newpath0 = substr($file,0,-4);
$newpath00 = substr($file,0,-4);




$image_table_arr[$i] .=(($image_counter + 1) % 3)? "" : "</tr>\n<tr><td><br></td></tr><tr valign=\"top\">";

$image_table_arr[$i] .= "\n<td valign=\"top\" width=\"240\"><table width=\"240\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" align=\"center\">\n";
$image_table_arr[$i] .= "\n<tr><td valign=\"top\" bgcolor=\"#ffff00\" width=\"240\"><table width=\"240\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\" align=\"center\">\n";
$image_table_arr[$i] .= "\n<tr><td valign=\"top\" bgcolor=\"#003366\" width=\"240\"><table width=\"240\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\" align=\"center\">\n";
$image_table_arr[$i] .= "\n<tr><td bgcolor=\"#000033\" align=\"center\"width=\"240\"><b>$newpath0</b></td></tr>\n";
$image_table_arr[$i] .= "\n<tr><td bgcolor=\"#000000\" width=\"240\"><a href='$path2$file' target='_blank' rel=\"thumbnail\"><img src=\"$path$file\" width=\"240\" border=\"0\"></a></td></tr>\n";
$image_table_arr[$i] .= "\n<tr><td bgcolor=\"#000033\" align=\"center\" width=\"240\"><IMG SRC=\"minus.gif\" CLASS=\"showstate\" ONCLICK=\"expandcontent(this, 'sc".$newpath0."')\" align=\"right\"><b>Information</b></td></tr>\n";
$image_table_arr[$i] .= "\n</table>\n";
$image_table_arr[$i] .= "\n<div id=\"sc".$newpath0."\" class=\"switchcontent\" width=\"240\">\n";
$image_table_arr[$i] .= "\n<table border=0 align=center cellspacing=0 cellpading=0 width=\"240\">\n";
$image_table_arr[$i] .= "\n<tr><td bgcolor=\"#ffffff\" align=\"left\" class=\"black0\" width=\"240\"><b class=\"black0\" width=\"240\">Description :<br></b>\n";
$image_table_arr[$i] .= file_get_contents ("Pictures/Pics/Commentaires/$newpath0.txt");
$image_table_arr[$i] .= "</td></tr>\n";
$image_table_arr[$i] .= "\n<tr><td bgcolor=\"#ffffff\" align=\"left\" class=\"black0\" width=\"240\"><br></td></tr>\n";
$image_table_arr[$i] .= "\n<tr><td valign=\"top\" bgcolor=\"#ffffff\" width=\"240\"><table width=\"240\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\" align=\"center\">\n";
$image_table_arr[$i] .= "<tr><td bgcolor=\"#ffffff\" align=\"left\" width=\"240\" valign=\"top\"><a href=\"rater0.php?var1=$newpath0&var00=$path$file\" target=\"autre\" title=\"Rate it! - Noter la !\" alt=\"Rate it!\" class=\"black000\"><script type=\"text/javascript\">ajaxinclude(\"rater1.php?var1=$newpath0&var00=$path$file\")</script></a></td>";
$image_table_arr[$i] .= "\n<td bgcolor=\"#ffffff\" align=\"center\" class=\"black0\" width=\"240\" colspan=\"2\">\n";
$image_table_arr[$i] .= file_get_contents ("Pictures/Pics/Vente/$newpath0.txt");
$image_table_arr[$i] .= "\n</table>\n";
$image_table_arr[$i] .= "\n<tr><td valign=\"top\" bgcolor=\"#ffffff\" width=\"240\"><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\">\n";
$image_table_arr[$i] .= "\n<tr><td bgcolor=\"#ffffff\" align=\"center\" width=\"240\"><a href=\"commentaires.php?var001=$newpath0&var002=$path$file\" target=\"autre\" title=\"Add comments - Ajout de commentaires.\" alt=\"Add comments - Ajout de commentaires\" class=\"white000\"><img src=\"".$output1."\" border=\"0\"></a></td>";
$image_table_arr[$i] .= "</td></tr>\n";
$image_table_arr[$i] .= "\n</table>\n";
$image_table_arr[$i] .= "\n</div>\n";
$image_table_arr[$i] .= "\n</table>\n";
$image_table_arr[$i] .= "\n</table>\n";
$image_table_arr[$i] .= "\n</table></td>\n\n\n";
$i++;
++$image_counter;
++$cell_counter;
}
}
$no_of_images = count($image_table_arr);
$colspan= ($row_counter * 3) - $cell_counter;



$to = 12;
if(isset($_GET['from']))
$from = $_GET['from'];
else
$from = -$no_of_images;
$from000 = substr($from, -1);

error_reporting(E_ALL);
ini_set('display_errors','Off');
$path4 = substr($path,24);


$i1 = $i+1;
$image_table_arr= array_slice($image_table_arr, $from, $to) or exit("<center><b> - No photo in this folder : ($path4) for now. <br><br>- Pas de photo dans ce dossier : ($path4) pour le moment.<br><br></b></center></table></table></div><!--content goes here --><b class=\"rbottom\"><b class=\"r4\"></b> <b class=\"r3\"></b> <b class=\"r2\"></b> <b class=\"r1\"></b></b></div></center>");
$image_table .= "\n<tr><td valign=\"top\" width=\"100%\" colspan=\"3\" ><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\">\n";
$image_table .= "\n<tr><td bgcolor=\"#000033\" class=\"white00\" width=\"680\" align=\"left\"><b class=\"white00\">Photos in - Photos dans :</b> $dirshort ";
$image_table .= "\n</td>";
$image_table .= "\n <td bgcolor=\"#000033\" align=\"right\" width=\"100\"><div class=\"Slideshow\"><a href=\"javascript:void(viewer.show(0))\">Slideshow</a></div></td></tr>\n";
$image_table .= "\n</td></tr>\n";
$image_table .= "\n<tr><td bgcolor=\"#cccccc\" class=\" white00\" align=\"right\" colspan=\"3\">\n";
$image_table .= "<script type=\"text/javascript\">ajaxinclude(\"../Muraille/Change-shoppingcart-button/change_shoppingcart_button.txt\")</script>";
$image_table .= "\n</td></tr>\n";
$image_table .= "\n<tr>\n";
$image_table .= "\n</table>\n";


// split page numericly
$image_table .= "\n<tr><td bgcolor=\"#cccccc\" align=\"center\" class=\"black002\" colspan=\"3\" width=\"100%\"><b class='black002'>Page : </b>";
$paginate = ceil($no_of_images/$to);




for ($i=0;$i<$paginate;$i++)
{
$from_val = $no_of_images-($to*$i);
$image_table .= "<a href='".$_SERVER['PHP_SELF']."?folder=$val1&from=-".$from_val."' >".($i+1)."</a>&nbsp;-&nbsp;";

}

echo '</td></tr>'.$image_table.''.implode("",$image_table_arr);
$image_table1 .= "</tr>\n\n";
$image_table1 .="<tr><td bgcolor=\"#cccccc\" align=\"center\" class=\"black002\" colspan=\"3\" width=\"780\"><br><b class='black002'>Page : </b>"; // split page numericly
for ($i=0;$i<$paginate;$i++)
{
$from_val = $no_of_images-($to*$i);

$image_table1 .= "<a href='".$_SERVER['PHP_SELF']."?folder=$val1&from=-".$from_val."' >".($i+1)."</a>&nbsp;-&nbsp;";

}

echo '<tr><td bgcolor="#cccccc" valign="top"><br><br></td></tr></table>'.$image_table1;



?>




Thanks to you !



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum