图片库——选择最先显示的图片
我有基于 jQuery scrip 的照片库[来自: http://coffeescripter.com/code/ad-画廊/。
图像存储在 mySQL 数据库中。我有一个包含画廊列表的页面,其中显示每个画廊的前五张图像。单击任何图像都会移动到图库并从第一张图像开始显示。
我想以这样的方式做到这一点:如果用户单击第二个图像,显示应该从第二个图像开始,如果用户单击第三个图像,显示应该从第三个图像开始等等。
这是一些代码,我到目前为止:
/* galleries.php */
<?php
$idg = $_GET["idg"];
if (file_exists(GALLERY.'galleries.php') && $idg == '')
{
require_once(GALLERY.'list_galleries.php');
}
else if (file_exists(GALLERY.'galleries.php') && $idg != '' )
{
require_once(GALLERY.'view_gallery.php');
}
?>
/* list_gallery.php */
<?php
$sql_gal = "SELECT id_g, nazwa FROM page_gallery WHERE widok=1";
$res_gal = @mysql_query($sql_gal);
$n = mysql_num_rows($res_gal);
while ($row_gal = @mysql_fetch_array($res_gal)){
$galName = $row_gal["nazwa"];
$idg = $row_gal["id_g"];
$sql_gal_con = "SELECT desc, img FROM page_gallery_con
WHERE id_g='$idg' ORDER BY order ASC LIMIT 5";
$res_gal_con = @mysql_query($sql_gal_con);
echo '<table class="galleryTable">';
echo '<tr >';
echo '<td colspan="4">';
echo '<a href="?p=13&idg='.$idg.'" class="galleryName" >'.$galName.'</a>';
echo '</td>';
echo '<td class="galleryCount">';
echo '</td>';
echo '</tr>';
echo '<tr class="galleryRow">';
while ($row_gal_con = @mysql_fetch_array($res_gal_con)){
$desc = $row_gal_con["desc"];
$img = $row_gal_con["img"];
echo '<td class="galleryCell">';
echo '<a href="?p=13&idg='.$idg.'"><img src="'.GALLERY_DIR.'min/'.$img.'" alt="'.$desc.'" /></a>';
echo '</td>';
}
echo '</tr>';
echo '</table>';
}
?>
I have photo gallery based on jQuery scrip[t from: http://coffeescripter.com/code/ad-gallery/.
Images are stored in mySQL database. I have a page with list of galleries, which displays first five images from each gallery. Clicking at any of image moves to gallery and starts displaying from first image.
I would like to do that in a such way: if user clicks on second image, displaying should start from second image, if user clicks on third image, displaying should start from third image etc.
Here is some code, which I have so far:
/* galleries.php */
<?php
$idg = $_GET["idg"];
if (file_exists(GALLERY.'galleries.php') && $idg == '')
{
require_once(GALLERY.'list_galleries.php');
}
else if (file_exists(GALLERY.'galleries.php') && $idg != '' )
{
require_once(GALLERY.'view_gallery.php');
}
?>
/* list_galleries.php */
<?php
$sql_gal = "SELECT id_g, nazwa FROM page_gallery WHERE widok=1";
$res_gal = @mysql_query($sql_gal);
$n = mysql_num_rows($res_gal);
while ($row_gal = @mysql_fetch_array($res_gal)){
$galName = $row_gal["nazwa"];
$idg = $row_gal["id_g"];
$sql_gal_con = "SELECT desc, img FROM page_gallery_con
WHERE id_g='$idg' ORDER BY order ASC LIMIT 5";
$res_gal_con = @mysql_query($sql_gal_con);
echo '<table class="galleryTable">';
echo '<tr >';
echo '<td colspan="4">';
echo '<a href="?p=13&idg='.$idg.'" class="galleryName" >'.$galName.'</a>';
echo '</td>';
echo '<td class="galleryCount">';
echo '</td>';
echo '</tr>';
echo '<tr class="galleryRow">';
while ($row_gal_con = @mysql_fetch_array($res_gal_con)){
$desc = $row_gal_con["desc"];
$img = $row_gal_con["img"];
echo '<td class="galleryCell">';
echo '<a href="?p=13&idg='.$idg.'"><img src="'.GALLERY_DIR.'min/'.$img.'" alt="'.$desc.'" /></a>';
echo '</td>';
}
echo '</tr>';
echo '</table>';
}
?>
I have found proper solution based on tips from http://webdev.plentyinfo.com/tag/ad-gallery/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需添加一个 if 条件来检查您的
$_GET
变量是否已设置。例如,在第二个查询之前,像这样更改代码just add a if condition to check if your
$_GET
variable is set or not. For example before your second query change your code like this