Now, my problem is this.
I want the images to be displayed in a horizontal rows of max 7 and max vertical rows of 4.
Something like this ( # = one image )
___________
|#|#|#|#|#|#|#|
|#|#|#|#|#|#|#|
|#|#|#|#|#|#|#|
|#|#|#|#|#|#|#|
Thats 28 images total. But it's also got to handle if there arn't 28 images to display. Something like this:
___________
|#|#|#|#|#|#|#|
|#|#|#|#|#|#|#|
|#|#|#|#|
Now, so far I have gotten these varibles made:
The number of horizontal rows, the number of images on the last horizontal row, the number of images in total on the page, the number of the first image out of all images, and the last number of the image on the page
Now, this is what I have so far:
<?php
$galimg = 28;
$images = 76
$row = 7;
/*
The important varibles:
Number of images per gallery = $galimg
The total number of set images = $images
The page number = $pg
The number of images per row = $row
The number of rows per page = $numrow
*/
$fsimg = ($pg - 1) * $galimg + 1;//first image
//total number of images on page
$onpage = $pg * $galimg;
$onpage = $images - $onpage;
$onpage = $onpage + $galimg;
if ($onpage > 28) {
$onpage = 28;
}
$laimg = $fsimg + ($onpage - 1);//Last image
//How many rows?
if ($onpage <= 7) { //One row
$numrow = 1;
} elseif ($onpage <= 14) { //Two rows
$numrow = 2;
} elseif ($onpage <= 21) { //Three rows
$numrow = 3;
} elseif ($onpage <= 28) { //Four rows
$numrow = 4;
}
//how many images in the last row?
$lastrow = ($numrow * 7) - $onpage;
$lastrow = 7 - $lastrow;
//Make number of images array
$imagename = range($fsimg, $laimg);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Gallery</title>
<link href="../style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
echo "# of rows: $numrow <br>
# on last row: $lastrow <br>
# on page: $onpage <br>
Last img: $laimg <br>
First img: $fsimg <br>";
foreach ($imagename as $display) {
echo "$display <br>";
}
?>
<table align="center">
<tr><td colspan="7" class="eventheader">Pictures</td></tr>
<?php
//put displaying info here
?>
</table>
</body>
</html>
Now, each row that exsists this is the code I want:<tr> //max 7 cells go here
And each cell is like this:
<td class="eventheader"><a href="image.php?num=$imagename"><img src="thumbs/$imagename.jpg" alt="Ninja" /></a></td>With "$imagename" being replaced by the image name/number.
