To jest przykładowa galeiria z mojej strony:
Kod
http://rammstein.c0.pl/module.php?op=galery&cmd=1
po kiknieciu na zdjecie zeby zobaczyc inne trzeba kliknąc wstecz a ja chciałbym zeby były strzałki < >
oto skrypt galerii
Kod
<?
function module_start($cmd) {
if($cmd=='add_now') {
add_row();
}
if ($cmd == 'showimg') show_img($GLOBALS['img']);
}
function module_main($cmd) {
global $gbook_limit, $page;
if($cmd=='') {
main_title_open();
echo 'Galeria';
main_title_close();
main_text_open();
list_cat();
main_text_close();
}
if($cmd<>'') {
main_title_open();
echo '<a href="module.php?op=galery">>>Powrót</a>';
main_title_close();
main_text_open();
echo '
';
show_minis($cmd, $page);
main_text_close();
}
}
function module_info($co) {
if($co=='title')
return 'galeria';
}
function module_type() {
return 'normal';
}
?>
<?
function list_cat() {
global $PHP_SELF, $op;
if(!function_exists(gal_inc)) include('module/galery.inc.php');
$query = "SELECT * FROM $gal_a_tbl ORDER BY title";
$result = mysql_query($query);
$ile = mysql_num_rows($result);
echo '
';
while($r = mysql_fetch_array($result)) {
$id = $r['id'];
$title = $r['title'];
$text = $r['text'];
$text = stripslashes($text);
$title = stripslashes($title);
$text = make_clickable($text);
$title = '<a href="module.php?op='.$op.'&cmd='.$id.'" class="t_list">'.$title.'</a></b>';
$qu = "SELECT * FROM $gal_b_tbl WHERE cat='$id'";
$re = mysql_query($qu);
$ile = mysql_num_rows($re);
$others = 'obrazów: <b>'.$ile.'</b>';
list_open();
list_body_open($title, $text, $others);
list_close();
}
}
function show_minis($cat, $page) {
global $art_tbl, $PHP_SELF, $arts, $op;
if(!function_exists(gal_inc)) include('module/galery.inc.php');
$query = "SELECT * FROM $gal_b_tbl WHERE cat='$cat' ORDER BY date DESC";
$result = mysql_query($query);
$ile = mysql_num_rows($result);
if($ile==0) echo '<center>Nie znaleziono żadnych obrazów w tej kategorii</center>
';
else {
if($ile<>0) {
$znk = $page * $gal_limit;
mysql_data_seek($result, $znk);
}
$aaa = 0;
$cols = 0;
echo '<table width="100%" cellpadding="1" cellspacing="1" border="0">
<tr>';
while($r = mysql_fetch_array($result)) {
$id = $r['id'];
$name = $r['name'];
$size = $r['size'];
$title = $r['title'];
if($cols==$gal_cols) {
$cols = 0;
echo '</tr>
<tr>';
}
echo '<td align="center" class="uni_02">
<a href="module.php?op='.$op.'&cmd=showimg&img='.$id.'.'.$name.'" title="['.$size.'kB]">
<img src="uploads/galery/m'.$id.'.'.$name.'" border="0">
</a>
'.$title.'
</td>';
$aaa++;
$cols++;
if($aaa==$gal_limit) break;
}
echo '</tr>
</table>';
echo '
<center>';
$ile = mysql_num_rows($result);
if($ile<>0) {
$arts= $ile;
$ile = $ile / $gal_limit;
$ile = ceil($ile);
$bbb = 0;
while($bbb<>$ile) {
$ccc = $bbb + 1;
if($page==$bbb) {
echo '[<b>'.$ccc.'</b>] ';
} else {
echo '[<a href="module.php?op='.$op.'&page='.$bbb.'&cmd='.$cat.'">'.$ccc.'</a>] ';
}
$bbb++;
}
} else {
echo '[<b>1</b>] ';
}
}
}
function show_img($img) {
include('module/galery.inc.php');
$img = explode('.',$img);
$query = "SELECT * FROM $gal_b_tbl WHERE id='$img[0]' && name='$img[1]'";
$result = mysql_query($query);
$r = mysql_fetch_array($result);
if (mysql_num_rows($result) == '0' || !file_exists("uploads/galery/$img[0].$img[1]")) {
echo 'nie znaleziono obrazka';
exit;
}
else {
echo '
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<link rel="stylesheet" href="theme/'.$GLOBALS['theme'].'/style.css">
<title> '.$GLOBALS['site_name'].' - galeria</title>
</head>
<body>
<center>
<img src="uploads/galery/'.$img[0].'.'.$img[1].'">
<font class="uni_02"><b>'.$r['title'].'</b>
[ <a href="javascript:history.back(1)"><font color="white">Wstecz</font></a> ]<font>
</center>
</body>
</html>
';
}
exit;
}
?>
function module_start($cmd) {
if($cmd=='add_now') {
add_row();
}
if ($cmd == 'showimg') show_img($GLOBALS['img']);
}
function module_main($cmd) {
global $gbook_limit, $page;
if($cmd=='') {
main_title_open();
echo 'Galeria';
main_title_close();
main_text_open();
list_cat();
main_text_close();
}
if($cmd<>'') {
main_title_open();
echo '<a href="module.php?op=galery">>>Powrót</a>';
main_title_close();
main_text_open();
echo '
';
show_minis($cmd, $page);
main_text_close();
}
}
function module_info($co) {
if($co=='title')
return 'galeria';
}
function module_type() {
return 'normal';
}
?>
<?
function list_cat() {
global $PHP_SELF, $op;
if(!function_exists(gal_inc)) include('module/galery.inc.php');
$query = "SELECT * FROM $gal_a_tbl ORDER BY title";
$result = mysql_query($query);
$ile = mysql_num_rows($result);
echo '
';
while($r = mysql_fetch_array($result)) {
$id = $r['id'];
$title = $r['title'];
$text = $r['text'];
$text = stripslashes($text);
$title = stripslashes($title);
$text = make_clickable($text);
$title = '<a href="module.php?op='.$op.'&cmd='.$id.'" class="t_list">'.$title.'</a></b>';
$qu = "SELECT * FROM $gal_b_tbl WHERE cat='$id'";
$re = mysql_query($qu);
$ile = mysql_num_rows($re);
$others = 'obrazów: <b>'.$ile.'</b>';
list_open();
list_body_open($title, $text, $others);
list_close();
}
}
function show_minis($cat, $page) {
global $art_tbl, $PHP_SELF, $arts, $op;
if(!function_exists(gal_inc)) include('module/galery.inc.php');
$query = "SELECT * FROM $gal_b_tbl WHERE cat='$cat' ORDER BY date DESC";
$result = mysql_query($query);
$ile = mysql_num_rows($result);
if($ile==0) echo '<center>Nie znaleziono żadnych obrazów w tej kategorii</center>
';
else {
if($ile<>0) {
$znk = $page * $gal_limit;
mysql_data_seek($result, $znk);
}
$aaa = 0;
$cols = 0;
echo '<table width="100%" cellpadding="1" cellspacing="1" border="0">
<tr>';
while($r = mysql_fetch_array($result)) {
$id = $r['id'];
$name = $r['name'];
$size = $r['size'];
$title = $r['title'];
if($cols==$gal_cols) {
$cols = 0;
echo '</tr>
<tr>';
}
echo '<td align="center" class="uni_02">
<a href="module.php?op='.$op.'&cmd=showimg&img='.$id.'.'.$name.'" title="['.$size.'kB]">
<img src="uploads/galery/m'.$id.'.'.$name.'" border="0">
</a>
'.$title.'
</td>';
$aaa++;
$cols++;
if($aaa==$gal_limit) break;
}
echo '</tr>
</table>';
echo '
<center>';
$ile = mysql_num_rows($result);
if($ile<>0) {
$arts= $ile;
$ile = $ile / $gal_limit;
$ile = ceil($ile);
$bbb = 0;
while($bbb<>$ile) {
$ccc = $bbb + 1;
if($page==$bbb) {
echo '[<b>'.$ccc.'</b>] ';
} else {
echo '[<a href="module.php?op='.$op.'&page='.$bbb.'&cmd='.$cat.'">'.$ccc.'</a>] ';
}
$bbb++;
}
} else {
echo '[<b>1</b>] ';
}
}
}
function show_img($img) {
include('module/galery.inc.php');
$img = explode('.',$img);
$query = "SELECT * FROM $gal_b_tbl WHERE id='$img[0]' && name='$img[1]'";
$result = mysql_query($query);
$r = mysql_fetch_array($result);
if (mysql_num_rows($result) == '0' || !file_exists("uploads/galery/$img[0].$img[1]")) {
echo 'nie znaleziono obrazka';
exit;
}
else {
echo '
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<link rel="stylesheet" href="theme/'.$GLOBALS['theme'].'/style.css">
<title> '.$GLOBALS['site_name'].' - galeria</title>
</head>
<body>
<center>
<img src="uploads/galery/'.$img[0].'.'.$img[1].'">
<font class="uni_02"><b>'.$r['title'].'</b>
[ <a href="javascript:history.back(1)"><font color="white">Wstecz</font></a> ]<font>
</center>
</body>
</html>
';
}
exit;
}
?>
i tabela w bazie:
Kod
--
-- Struktura tabeli dla `galery_b`
--
CREATE TABLE IF NOT EXISTS `galery_b` (
`id` int(32) NOT NULL auto_increment,
`cat` varchar(32) collate utf8_polish_ci NOT NULL,
`title` varchar(64) collate utf8_polish_ci NOT NULL,
`date` datetime NOT NULL default '0000-00-00 00:00:00',
`name` varchar(16) collate utf8_polish_ci NOT NULL default '0',
`size` varchar(32) collate utf8_polish_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci AUTO_INCREMENT=265;
-- Struktura tabeli dla `galery_b`
--
CREATE TABLE IF NOT EXISTS `galery_b` (
`id` int(32) NOT NULL auto_increment,
`cat` varchar(32) collate utf8_polish_ci NOT NULL,
`title` varchar(64) collate utf8_polish_ci NOT NULL,
`date` datetime NOT NULL default '0000-00-00 00:00:00',
`name` varchar(16) collate utf8_polish_ci NOT NULL default '0',
`size` varchar(32) collate utf8_polish_ci NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_polish_ci AUTO_INCREMENT=265;