Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Galeria oparta na php a lightbox, Problem z lightbox'em
slawekhofi
post 10.05.2010, 15:22:27
Post #1





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 10.05.2010

Ostrzeżenie: (0%)
-----


Witam wszystkich!

Sorki za tak banalne (niestety nie dla mnie) pytanie, co więcej widziałem podobne tematy na forum dotyczące lightboxa, ale wybaczcie jestem nowym użytkownikownikiem tego forum. Do rzeczy mam pewien skrypt, który wyświetla balerię zdjęć. Skrypt jest oparty na plikach i na sql. Problem w tym, że nie wiem jak skonfigurować ten skrypt, tak aby po kliknięciu na zdjęcie otwierało się w lightboxie. Proszę o pomoc

poniżej skrypt:

<html>
<head>
<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>

<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />

</head>
<body>
<?php
include("config.inc.php");

// initialization
$result_array = array();
$counter = 0;

$cid = (int)($_GET['cid']);
$pid = (int)($_GET['pid']);

// Category Listing

if( empty($cid) && empty($pid) )
{
$number_of_categories_in_row = 4;

$result = mysql_query( "SELECT c.category_id,c.category_name,COUNT(photo_id)
FROM gallery_category as c
LEFT JOIN gallery_photos as p ON p.photo_category = c.category_id
GROUP BY c.category_id" );
while( $row = mysql_fetch_array( $result ) )
{
$result_array[] = "<a href='viewgallery.php?cid=".$row[0]."'>".$row[1]."</a> "."(".$row[2].")";
}
mysql_free_result( $result );

$result_final = "<tr>\n";

foreach($result_array as $category_link)
{
if($counter == $number_of_categories_in_row)
{
$counter = 1;
$result_final .= "\n</tr>\n<tr>\n";
}
else
$counter++;

$result_final .= "\t<td>".$category_link."</td>\n";
}

if($counter)
{
if($number_of_categories_in_row-$counter)
$result_final .= "\t<td colspan='".($number_of_categories_in_row-$counter)."'>&nbsp;</td>\n";

$result_final .= "</tr>";
}
}


// Thumbnail Listing

else if( $cid && empty( $pid ) )
{
$number_of_thumbs_in_row = 5;

$result = mysql_query( "SELECT photo_id,photo_caption,photo_filename FROM gallery_photos WHERE photo_category='".addslashes($cid)."'" );
$nr = mysql_num_rows( $result );

if( empty( $nr ) )
{
$result_final = "\t<tr><td>Nie ma zdjęć w galerii</td></tr>\n";
}
else
{
while( $row = mysql_fetch_array( $result ) )
{
$result_array[] = "<a href='viewgallery.php?cid=$cid&pid=".$row[0]." '><img src='".$images_dir."/tb_".$row[2]."' border='0' alt='".$row[1]."' /></a>";
}
mysql_free_result( $result );

$result_final = "<tr>\n";

foreach($result_array as $thumbnail_link)
{
if($counter == $number_of_thumbs_in_row)
{
$counter = 1;
$result_final .= "\n</tr>\n<tr>\n";
}
else
$counter++;

$result_final .= "\t<td>".$thumbnail_link."</td>\n";
}

if($counter)
{
if($number_of_photos_in_row-$counter)
$result_final .= "\t<td colspan='".($number_of_photos_in_row-$counter)."'>&nbsp;</td>\n";

$result_final .= "</tr>";
}
}
}

// Full Size View of Photo
else if( $pid )
{
$result = mysql_query( "SELECT photo_caption,photo_filename FROM gallery_photos WHERE photo_id='".addslashes($pid)."'" );
list($photo_caption, $photo_filename) = mysql_fetch_array( $result );
$nr = mysql_num_rows( $result );
mysql_free_result( $result );

if( empty( $nr ) )
{
$result_final = "\t<tr><td>Nie ma zdjęć w galerii</td></tr>\n";
}
else
{
$result = mysql_query( "SELECT category_name FROM gallery_category WHERE category_id='".addslashes($cid)."'" );
list($category_name) = mysql_fetch_array( $result );
mysql_free_result( $result );

$result_final .= "<tr>\n\t<td>
<a href='viewgallery.php'>Categories</a> &gt;
<a href='viewgallery.php?cid=$cid'>$category_name</a></td>\n</tr>\n";

$result_final .= "<tr>\n\t<td align='center'>
<br />
<img src='".$images_dir."/".$photo_filename."' border='0' alt='".$photo_caption."' />
<br />
$photo_caption
</td>
</tr>";
}
}

// Final Output
echo <<<__HTML_END

<html>
<head>
<title>Gallery View</title>
</head>
<body>
<table width='100%' border='0' align='center' style='width: 100%;'>
$result_final
</table>
</body>
</html>

__HTML_END;
?>
</body>
</html>

Go to the top of the page
+Quote Post
piotrooo89
post 10.05.2010, 15:54:01
Post #2


Newsman


Grupa: Moderatorzy
Postów: 4 005
Pomógł: 548
Dołączył: 7.04.2008
Skąd: Trzebinia/Kraków




proszę dodanie odpowiedniego bbcode.


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 26.04.2024 - 09:48