Jump to content

[SOLVED] Paginate a result


Peuplarchie

Recommended Posts

Good day to you,

      I need to paginate the result of this code :

 


<?php
$image_counter = -1;
$row_counter = 0;
$cell_counter = 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 = "http://ponder.peuplies.info/V_0-1/Muraille/Change-comment-icon/comment_icon_change.txt";
$fh1 = fopen($comicon, 'r');
$outputt1 = fgets($fh1);
$output1 = str_replace("../..", "http://ponder.peuplies.info/V_0-1", $outputt1 );
fclose($fh1);




$dir_handle = @opendir($path) or die("Unable to open $path");
$image_table = "<table valign=\"top\" align=\"center\" width=\"100%\">\n";
$image_table .= "\n<tr><td bgcolor=\"#cccccc\" align=\"center\" colspan=\"3\"><table valign=\"top\" align=\"center\" width=\"100%\" border=\"0\" cellspacing=\"0\">\n";
$image_table .= "\n<tr><td bgcolor=\"#000033\" class=\" white00\" align=\"left\"><b class=\"white00\">Photos in - Photos dans :</b> $dirshort</td>";
$image_table .= "\n    <td bgcolor=\"#000033\" align=\"right\" ><br></td></tr>\n";
$image_table .= "\n<tr><td bgcolor=\"#cccccc\" class=\" white00\" align=\"right\" colspan=\"2\">\n";
$image_table .= "<script type=\"text/javascript\">ajaxinclude(\"http://ponder.peuplies.info/V_0-1/Muraille/Change-shoppingcart-button/change_shoppingcart_button.txt\")</script>";
$image_table .= "\n</td></tr>\n";
$image_table .= "\n</table><tr>\n";
while (false !== ($file = readdir($dir_handle))) {
  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 .=(($image_counter + 1) % 3)? "" : "</tr>\n<tr><td><br></td></tr><tr valign=\"top\">";
      $image_table .= "\n<td valign=\"top\" width=\"180\"><table width=\"180\" border=\"0\" cellpadding=\"0\" cellspacing=\"1\" align=\"center\">\n";
      $image_table .= "\n<tr><td valign=\"top\" bgcolor=\"#ffff00\" width=\"180\"><table width=\"180\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\" align=\"center\">\n";
      $image_table .= "\n<tr><td valign=\"top\" bgcolor=\"#003366\" width=\"180\"><table width=\"180\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\" align=\"center\">\n";
      $image_table .= "\n<tr><td bgcolor=\"#000033\" align=\"center\"width=\"180\"><b>$newpath0</b></td></tr>\n";
      $image_table .= "\n<tr><td bgcolor=\"#000000\" width=\"180\"><a href='http://ponder.peuplies.info/V_0-1/Art/$path2$file' target='_blank' rel=\"thumbnail\"><img src=\"http://ponder.peuplies.info/V_0-1/Art/$path$file\" width=\"180\" border=\"0\"></a></td></tr>\n";
      $image_table .= "\n<tr><td bgcolor=\"#000033\" align=\"center\" width=\"180\"><IMG SRC=\"http://ponder.peuplies.info/V_0-1/Art/minus.gif\" CLASS=\"showstate\" ONCLICK=\"expandcontent(this, 'sc".$newpath0."')\" align=\"right\"><b>Information</b></td></tr>\n";
      $image_table .= "\n</table>\n";
      $image_table .= "\n<div id=\"sc".$newpath0."\" class=\"switchcontent\" width=\"180\">\n";
      $image_table .= "\n<table border=0 align=center cellspacing=0 cellpading=0 width=\"180\">\n";
      $image_table .= "\n<tr><td bgcolor=\"#ffffff\" align=\"left\" class=\"black0\" width=\"180\"><b class=\"black0\" width=\"180\">Description :<br></b><script type=\"text/javascript\">ajaxinclude(\"http://ponder.peuplies.info/V_0-1/Art/Pictures/Pics/Commentaires/$newpath0.txt\")</script></td></tr>\n";
      $image_table .= "\n<tr><td bgcolor=\"#ffffff\" align=\"left\" class=\"black0\" width=\"180\"><br></td></tr>\n";
      $image_table .= "\n<tr><td valign=\"top\" bgcolor=\"#ffffff\" width=\"180\"><table width=\"180\" border=\"0\" cellpadding=\"1\" cellspacing=\"0\" align=\"center\">\n";
      $image_table .= "<tr><td bgcolor=\"#ffffff\" align=\"left\" width=\"180\" valign=\"top\"><a href=\"http://ponder.peuplies.info/V_0-1/Art/rater0.php?var1=$newpath0&var00=$path$file\" target=\"autre\" title=\"Rate it! - Noter la !\" alt=\"Rate it!\" class=\"black000\"><script type=\"text/javascript\">ajaxinclude(\"http://ponder.peuplies.info/V_0-1/Art/rater1.php?var1=$newpath0&var00=$path$file\")</script></a></td>";
      $image_table .= "\n<td bgcolor=\"#ffffff\" align=\"center\" class=\"black0\" width=\"180\" colspan=\"2\"><script type=\"text/javascript\">ajaxinclude(\"http://ponder.peuplies.info/V_0-1/Art/Pictures/Pics/Prix/$newpath0.txt\")</script><script type=\"text/javascript\">ajaxinclude(\"http://ponder.peuplies.info/V_0-1/Art/Pictures/Pics/Vente/$newpath0.txt\")</script></td></tr>\n";
      $image_table .= "\n</table>\n";
      $image_table .= "\n<tr><td valign=\"top\" bgcolor=\"#ffffff\" width=\"180\"><table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\">\n";
      $image_table .= "\n<tr><td bgcolor=\"#ffffff\" align=\"left\" width=\"180\"><a href=\"http://ponder.peuplies.info/V_0-1/Art/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 .= "</td></tr>\n";
      $image_table .= "\n</table>\n";
      $image_table .= "\n</div>\n";
      $image_table .= "\n</table>\n";
      $image_table .= "\n</table>\n";
      $image_table .= "\n</table></td>\n\n\n";

      ++$image_counter;
      ++$cell_counter;
  }
}
$colspan= ($row_counter * 3) - $cell_counter;
$image_table .= ($cell_counter % 3) ?  "<td colspan=$colspan valign=top> </td>" : "";
$image_table .= "</tr>\n</table>\n";
echo "$image_table<br><br>";

?> 


 

 

 

This code read a given directory and output image with info formated in rows of 3.

 

Now I need that the code after 4 row would create a link to go to the nexts images.

 

Thanks !

Link to comment
https://forums.phpfreaks.com/topic/76941-solved-paginate-a-result/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.