Kasak Tahilramani
02-06-2007, 08:05 PM
This problem will require you to create a single page that takes images from a directory and display them on a single page using a class. The page will show the smaller images in a table format. When an image is clicked it will open the larger version of the image in a new window.
Display six images per page by default. The user should be able to select between 4, 6, 8, or 10 images per page.
Here is the basic structure of the class I created. Created the file Gallery_class.php
code:
<?php
class Gallery {
private $directory;
private $images;
private $img_per_page;
function __construct($dir, $ipp=6) {
$this->images = array();
$this->directory = $dir;
$this->images_per_page($ipp);
}
# Opens the directory and reads in the files to be displayed
private function get_images() {
}
# Outputs HTML for the page with the images
public function display_page() {
print "<table>";
#loop thru images equal to $this->img_per_page
# if ( $i is even )
# print "</tr><tr>";
# print image tag with filename to image
print "</table>";
}
# Outputs HTML for just a single image, the large one
public function display_image($file) {
}
# Sets the number of images per page
public function images_per_page($num) {
# if $num is a valid number of images
# set $this->img_per_page to $num
# else
# set $this->img_per_page to 6
}
}
?>
PHP script. Create the file :- gallery.php
code:
<HTML><HEAD></HEAD><BODY>
<?php
require "_Gallery_class.php";
$dir = "images";
$ipp = @$_GET['ipp'];
# <a href="http://russet/gallery.php?ipp=6">6</a>
$image = @basename($_GET['file']); # just the filename
$gallery = new Gallery($dir, $ipp);
if ($image) {
$gallery->display_image($image);
} else {
$gallery->display_page();
}
?>
</BODY></HTML>
ANd third file will be gallery.html where I will have my interface.
code:
where I will have select button with option vlaue 4 6 8 10 and if user hits the button "displayimage" respective num of images will be displayed.
I am not able to configure how my .html .php and third file gallery_class.php will interact with each other.
Anybody can please help in this problem.I had written in text my logic but not able to create html file and interaction between them.
Display six images per page by default. The user should be able to select between 4, 6, 8, or 10 images per page.
Here is the basic structure of the class I created. Created the file Gallery_class.php
code:
<?php
class Gallery {
private $directory;
private $images;
private $img_per_page;
function __construct($dir, $ipp=6) {
$this->images = array();
$this->directory = $dir;
$this->images_per_page($ipp);
}
# Opens the directory and reads in the files to be displayed
private function get_images() {
}
# Outputs HTML for the page with the images
public function display_page() {
print "<table>";
#loop thru images equal to $this->img_per_page
# if ( $i is even )
# print "</tr><tr>";
# print image tag with filename to image
print "</table>";
}
# Outputs HTML for just a single image, the large one
public function display_image($file) {
}
# Sets the number of images per page
public function images_per_page($num) {
# if $num is a valid number of images
# set $this->img_per_page to $num
# else
# set $this->img_per_page to 6
}
}
?>
PHP script. Create the file :- gallery.php
code:
<HTML><HEAD></HEAD><BODY>
<?php
require "_Gallery_class.php";
$dir = "images";
$ipp = @$_GET['ipp'];
# <a href="http://russet/gallery.php?ipp=6">6</a>
$image = @basename($_GET['file']); # just the filename
$gallery = new Gallery($dir, $ipp);
if ($image) {
$gallery->display_image($image);
} else {
$gallery->display_page();
}
?>
</BODY></HTML>
ANd third file will be gallery.html where I will have my interface.
code:
where I will have select button with option vlaue 4 6 8 10 and if user hits the button "displayimage" respective num of images will be displayed.
I am not able to configure how my .html .php and third file gallery_class.php will interact with each other.
Anybody can please help in this problem.I had written in text my logic but not able to create html file and interaction between them.