PHP kod funkar inte......
jag har ett problem.. med PHP..
mina koder funkar inte eller så e det jag som inte vet hur man publiserad det... och allt ligger i samma map.. och det e ett galleri
koder:
<?php include_once("CustomGallery.definition.php") ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><?php echo $gallery->getTitle() ?> / Thumbnails</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body class="thumbnails">
<div id="header">
<h1><?php echo $gallery->getTitle() ?></h1>
</div>
<div id="content">
<?php echo $gallery->getThumbnailsDisplay() ?>
<br style="clear:both" />
</div>
</body>
</html>
____________________________________________________________
<?php include_once("CustomGallery.definition.php") ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title><?php echo $gallery->getTitle() ?> / Photo <?php echo $gallery->getActiveDisplay() ?></title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body class="photo">
<div id="header">
<h1><?php echo $gallery->getTitle() ?></h1>
</div>
<div id="navigation">
<p><?php echo $gallery->getCountDisplay() ?> | <?php echo $gallery->getPreviousDisplay() ?> | <?php echo $gallery->getNextDisplay() ?> | <a href="index.php" title="View Thumbnails">Back to Thumbnails</a></p>
</div>
<div id="content">
<p><?php echo $gallery->getActiveTextDisplay() ?></p>
<p><?php echo $gallery->getActiveImageDisplay() ?></p>
</div>
</body>
</html>
____________________________________________________________
<?php
Class Gallery {
var $photo_array;
var $image_directory;
var $active_index;
function Gallery(){
$this->photo_array = array();
$this->image_directory = "";
$this->active_index = null;
}
// set data
function addPhoto($image, $thumb, $text){
$photo = array("image" => $image, "thumb" => $thumb, "text" => $text);
array_push($this->photo_array, $photo);
}
// get data
function getActiveText(){
return $this->photo_array[$this->getActive()]["text"];
}
function getActiveImage(){
return $this->getDirectory() . $this->photo_array[$this->getActive()]["image"];
}
function getThumbnails(){
$result = array();
for($i = 0; $i < $this->getCount(); $i++){
array_push($result, $this->getDirectory() . $this->photo_array[$i]["thumb"]);
}
return $result;
}
// get/set directory
function setDirectory($directory){
$this->image_directory = $directory;
}
function getDirectory(){
return $this->image_directory;
}
// get/set index
function setActive($index){
$this->active_index = $index;
}
function getActive(){
return $this->active_index;
}
function getPrevious(){
$index = $this->getActive();
return ($index > 0) ? $index-1 : null;
}
function getNext(){
$index = $this->getActive();
return ($index < $this->getCount()-1) ? $index+1 : null;
}
function getCount(){
return count($this->photo_array);
}
}
?>
____________________________________________________________
<?php
include_once("CustomGallery.class.php");
$gallery = new CustomGallery();
$gallery->setTitle("My Gallery");
$gallery->setDirectory("photos/");
$gallery->addPhoto ( "photo_01.jpg", "tn_photo_01.jpg", "This is the caption for photo 1." );
$gallery->addPhoto ( "photo_02.jpg", "tn_photo_02.jpg", "This is the caption for photo 2." );
$gallery->addPhoto ( "photo_03.jpg", "tn_photo_03.jpg", "This is the caption for photo 3." );
$gallery->addPhoto ( "photo_04.jpg", "tn_photo_04.jpg", "This is the caption for photo 4." );
$gallery->addPhoto ( "photo_05.jpg", "tn_photo_05.jpg", "This is the caption for photo 5." );
$gallery->addPhoto ( "photo_06.jpg", "tn_photo_06.jpg", "This is the caption for photo 6." );
$gallery->addPhoto ( "photo_07.jpg", "tn_photo_07.jpg", "This is the caption for photo 7." );
$gallery->addPhoto ( "photo_08.jpg", "tn_photo_08.jpg", "This is the caption for photo 8." );
?>
____________________________________________________________
<?php
include_once("Gallery.class.php");
class CustomGallery extends Gallery {
var $title;
function CustomGallery(){
$this->Gallery();
$this->title = "";
$index = isset($_GET["id"]) ? $_GET["id"]-1 : 0;
Gallery::setActive($index);
}
// get/set title
function setTitle($title){
$this->title = $title;
}
function getTitle(){
return $this->title;
}
// get/set display index
function getActiveDisplay(){
return ($this->getActive()+1);
}
function getCountDisplay(){
return $this->getActiveDisplay() ." of ". $this->getCount();
}
function getPreviousDisplay(){
$index = $this->getPrevious();
if(is_int($index)) return "<a href=\"photo.php?id=".($index+1)."\" title=\"Previous Photo\">Previous</a>";
else return "<span>Previous</span>";
}
function getNextDisplay(){
$index = $this->getNext();
if(is_int($index)) return "<a href=\"photo.php?id=".($index+1)."\" title=\"Next Photo\">Next</a>";
else return "<span>Next</span>";
}
// get/set display data
function getActiveTextDisplay(){
return $this->getActiveText();
}
function getActiveImageDisplay(){
$image = $this->getActiveImage();
$index = $this->getActiveDisplay();
list($width, $height) = getimagesize($image);
return "<img src=\"$image\" width=\"$width\" height=\"$height\" alt=\"Photo $index\" />";
}
function getThumbnailsDisplay(){
$thumbnails = $this->getThumbnails();
$result = "";
for($i = 0; $i < count($thumbnails); $i++){
$index = $i+1;
$thumb = $thumbnails[$i];
list($width, $height) = getimagesize($thumb);
$result .= "<span><a href=\"photo.php?id=$index\" title=\"View Photo $index\"><img src=\"$thumb\" width=\"$width\" height=\"$height\" alt=\"Thumbnail $index\" /></a></span>";
}
return $result;
}
}
?>
ja det e mit problem..... Plz Hjälp mig...