Jump to content

[SOLVED] dynamicly creating multiple page


TGWSE_GY

Recommended Posts

Hi guys,

 

I am pulling images dynamically from a directory and resizing them with another script.  However I am wanting to after say 20 images stop the displaying of images and then provide a next link and pick up where I left off for the next 20 images on the following page and etc. untill I get to the last image.

 

Here is a link to what I am doing: http://www.hmtotc.com/private/george/projects/dandj3/index.php

 

 

and here is the code for my script that generates the images on the right hand side of the screen.

 

<?
include('db_con.php');
//define the path as relative
$path = "http://www.hmtotc.com/private/george/projects/dandj3/gallery";
$target = "gallery/";
//using the opendir function
$dir_handle = @opendir($path) or die("Unable to open $path");
$count = 0;
//echo "Directory Listing of $path<br/>";
echo "<table align=\"center\" cellpadding=\"2\" cellspacing=\"1\"><tr valign=\"bottom\">";
//running the while loop
while ($file = readdir($dir_handle)) {
   //echo "<img src=\"$target$file\" />";
    $query = mysql_query("SELECT Votes FROM image_info WHERE ImgName='$file'");
   $results = mysql_fetch_assoc($query);
   $votes = $results['Votes'];
   if ($file != "." && $file != "..") {
   echo "<td>";
   echo "<a rel=\"lightbox\" href=\"$target$file\" ><img src=\"resize.php?percent=20&img=$target$file\" border=\"0\"  /></a>";
   echo "<br />";
   echo "Votes: $votes";
   echo "<br />";
   echo "<a href=\"vote.php?id=$file\">VOTE</a>";
   echo "</td>";
   $count = $count + 1;
   if ($count == 3) {
	   echo "</tr>";
	   echo "<tr valign=\"bottom\">";
	   $count = 0;
   }
   }
}

//closing the directory
closedir($dir_handle);

if ($count > 3) {
echo "</tr>";
echo "</table>";
} elseif ($count == 0) {
echo "</table>";
}
?> 

 

 

Any help would be greatly appreciated guys. Thanks in advance

George!  8)

Link to comment
Share on other sites

Thanks ben, however that tutorial is talking about pulling from a database of information and I am using a directory. Would I have to have a temporary table for this in my db then and use that to process, or could I simply use a cookie to count say 1-20, when the click next on the first page the script looks at a cookie sees that 1-20 has previously been displayed and skips the first 20 images in the directory and displays 21 to 30.... etc. Or am I going to need to create a table a new table for the images all together?

 

Thanks

George!  8)

Link to comment
Share on other sites

well ideally you want to be just taking 20 images from the directory as you need them otherwise you will be downloading every image everytime...

 

Of course you could implement some sort of cache to speed things up...

 

How many images are we talking maximum?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.