Jump to content

ajax photo gallery


cmb

Recommended Posts

So what i'm trying to do is a user selects a gallery, and then it shows up with out the page reloading. The number of pictures varies in each gallery. This is what i have attempted but instead of showing the images in the div nothing happens, but looking at the source code in the developer tools it is there.

Ajax code:

<script type="text/javascript">
function ajax(gal){
$.ajax({
  cache: false,	
  type: "GET",
  url: "ths.php",
  data: "gal=" + gal,
  success: function(p){
    document.getElementById('thumbs').innerHTML = p;
  }
});
}
</script>

 

php code:

<?php
include("database.php");
$gal = $_GET['gal'];
$query = "SELECT * FROM ths_soccer WHERE Gallery_no = '$gal'";
$results = mysql_query($query);
$row = mysql_fetch_assoc($results);

$x = $row['no_Pics'];
$gender = $row['Gender'];			
$day = $row['Date_Played'];
$y = 1;

echo "<ul class='thumbs noscript'>";
echo " <script type=\"text/javascript\" src=\"../../js/jquery.galleriffic.js\"></script>";
echo "<ul class='thumbs noscript'>";
  	
if ($x == 0){
 echo "<li> <a  class='thumb' href='../../images/nopics.jpg' title=''><img src='../../images/nopicsthumb.jpg ' /></a></li>";	
}else if ($x == 10000){
 echo "<li> <a  class='thumb' href='../../images/coming.jpg' title=''><img src='../../images/comingthumb.jpg ' /></a></li>";
}else{
  while ($y <= $x){
 echo "<li> <a  class='thumb' href='../../images/Sections/ths/" . $gender . "/" . $day . "/" . $y . ".jpg' title=''><img src='../../images/Sections/ths/" . $gender . "/" . $day . "/thumbs/" . $y . ".jpg ' /></a><div class='caption'><div	class='download'><a href='../../images/Sections/ths/" . $gender . "/" . $day . "/big/" . $y . ".jpg ' target='_blank' />Download</a></div></div></li>";
								$y ++  ;	
  }
}
echo "</ul>";
echo "</ul>";
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.