<?php
$albumName = "Basic PHP Photo Album";
$p = $_GET['p'];
if ($handle = opendir("images")) {
$i = 1;
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$img[$i] = $file;
if ($p == $img[$i]) {
$ci = $i;
}
$i++;
}
}
closedir($handle);
$ti = $i - 1;
$pi = $ci - 1;
if ($p == "") {
$ni = $ci + 2;
} else {
$ni = $ci + 1;
}
$prevNext = "";
if ($pi > 0) {
$piFile = $img[$pi];
$prevNext .= "<a href=\"" . $_SERVER['PHP_SELF'] . "?p=" . $piFile . "\" title=\"show previous image\">«</a>";
} else {
$prevNext .= "«";
}
$prevNext .= " | ";
if ($ni <= $ti) {
$niFile = $img[$ni];
$prevNext .= "<a href=\"" . $_SERVER['PHP_SELF'] . "?p=" . $niFile . "\" title=\"show next image\">»</a>";
} else {
$prevNext .= "»";
}
if ($p == "") {
$p = $img[1];
}
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?php echo $albumName; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="imagetoolbar" content="no">
<style type="text/css">
body {
font-family: arial, helvetica, sans-serif;
margin: 10px;
padding: 0px 0px 0px 0px;
font-size: 11px;
background-color: #ffffff;
color: #333333;
}
td, select, input {
font-family: arial, helvetica, sans-serif;
font-size: 11px;
}
p {
font-family: arial, helvetica, sans-serif;
font-size: 11px;
line-height: 16px;
}
h1 {
font-family: georgia, times, times new roman, serif;
font-size: 18px;
font-weight: bold;
margin: 0px 0px 10px 0px;
}
.hRule {
border-top: 1px solid #cdcdcd;
margin: 0px 0px 10px 0px;
}
img {
border: 1px solid #333333;
}
.nextPrevious {
font-size: 18px;
color: #cdcdcd;
padding-bottom: 15px;
}
a, a:visited {
color: #cc0000;
text-decoration: none;
}
a:active, a:hover {
color: #cc0000;
text-decoration: underline;
}
</style>
</head>
<body>
<h1><?php echo $albumName; ?></h1>
<div class="hRule"></div>
<table border="0" cellpadding="0" cellspacing="0" align="center">
<tr align="center">
<td class="nextPrevious"><?php echo $prevNext; ?></td>
</tr>
<tr align="center">
<td><img src="images/<?php echo $p; ?>" alt="<?php echo $$albumName; ?>" border="0">
</td>
</tr>
</table>
</body>
</html>
ok.. selamat mencoba
1 Comments
Ane belum ngarti :e: masalah php, untuk kode diatas nantinya di taro dimana gan?
ReplyDeleteSelamet ya, emoticon komentarnya dah berhasil
Apabila ada pesan maupun saran silahkan berbagi dan memberikan komentar sobat di sini. Sebelumnya Terimakasih :)