php - Image Gallery -- select image which displays first -
i have photo gallery based on jquery scrip[t from: http://coffeescripter.com/code/ad-gallery/.
images stored in mysql database. have page list of galleries, displays first 5 images each gallery. clicking @ of image moves gallery , starts displaying first image.
i in such way: if user clicks on second image, displaying should start second image, if user clicks on third image, displaying should start third image etc.
here code, have 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 page_gallery 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 page_gallery_con id_g='$idg' order 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 http://webdev.plentyinfo.com/tag/ad-gallery/
just add if condition check if $_get
variable set or not. example before second query change code this
if(isset($_get['idg'])) $idg=$_get['idg']; else $idg = $row_gal["id_g"];
Comments
Post a Comment