front page photo slideshow

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
webdzine
Forum Newbie
Posts: 20
Joined: Wed Dec 08, 2010 12:40 am

front page photo slideshow

Post by webdzine »

anybody know of any good photo slideshow script that i can add to my frontpage of my site,
i want the pictures to load be pulled from the database if that is possible.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: front page photo slideshow

Post by Christopher »

I recently used this amazing little jQuery on-liner to create a basic slideshow on a website. I am a happy customer.

http://snook.ca/archives/javascript/sim ... -slideshow

You could easily get the images from a database.
(#10850)
webdzine
Forum Newbie
Posts: 20
Joined: Wed Dec 08, 2010 12:40 am

Re: front page photo slideshow

Post by webdzine »

so i got the slideshow to work but when i try to pull the images from the db they dont come up

Code: Select all

<?php
$imgurl = 'www.***********.com/images/pictures/';

$queryclient = "SELECT * FROM pictures WHERE type='1'";
$rscat = mysql_query($queryclient) or die('Error, query failed');
while($rowcat=mysql_fetch_object($rscat)){
?>
  <img src="http://<? $imgurl; ?><? echo $rowcat->image; ?>">
<? } ?>
if i put in the actual url of the image it comes up ok
how can i get it to pull from the db?
webdzine
Forum Newbie
Posts: 20
Joined: Wed Dec 08, 2010 12:40 am

Re: front page photo slideshow

Post by webdzine »

?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: front page photo slideshow

Post by Christopher »

Did you read that post? You need to link to the jQuery library, add the CSS they provide, initialize jQuery, and put the images in a <div> with a specific class name. Did you do all of that? All you show is getting the images, but not where you insert that HTML.
(#10850)
webdzine
Forum Newbie
Posts: 20
Joined: Wed Dec 08, 2010 12:40 am

Re: front page photo slideshow

Post by webdzine »

Here is the code that i have in the site, yet nothing shows up

Code: Select all

<script>
$(function(){
    $('.fadein img:gt(0)').hide();
    setInterval(function(){
      $('.fadein :first-child').fadeOut()
         .next('img').fadeIn()
         .end().appendTo('.fadein');}, 
      3000);
});
</script>
<style>
.fadein {
position:relative; 
width:661px; 
height:501px;
}

.fadein img {
position:absolute;
left:0;
top:0;
padding: 5px 165.5px;
height:480px;
width:406px;
}
</style>
<div class="fadein" >
<?php
$imgurl = '/images/homepage/';

$queryclient = "SELECT * FROM pictures_homepage";
$rscat = mysql_query($queryclient) or die('Error, query failed');
while($rowcat=mysql_fetch_object($rscat)){
?>
<img src="/images/homepage/<?php echo $rowcat['image']; ?>" >
<? } ?>
</div>
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: front page photo slideshow

Post by Christopher »

You might need to put the styles before the script.
(#10850)
webdzine
Forum Newbie
Posts: 20
Joined: Wed Dec 08, 2010 12:40 am

Re: front page photo slideshow

Post by webdzine »

Nope. Still doesn't show the images.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: front page photo slideshow

Post by Christopher »

Well ... it is probably some tiny detail wrong. Did you ever get their demo working on your site? (http://snook.ca/technical/fade/fade.html) If you get that working then try hard coding your images to replace theirs. The add the loop.
(#10850)
webdzine
Forum Newbie
Posts: 20
Joined: Wed Dec 08, 2010 12:40 am

Re: front page photo slideshow

Post by webdzine »

when i put the the full image like in the demo then it works but when i try to put the code for it to pull from the db it doesn't work.
please let me know if you see anything in my code

Code: Select all

<script>
$(function(){
    $('.fadein img:gt(0)').hide();
    setInterval(function(){
      $('.fadein :first-child').fadeOut()
         .next('img').fadeIn()
         .end().appendTo('.fadein');}, 
      3000);
});
</script>
<style>
.fadein { position:relative; width:500px; height:332px; }
.fadein img { position:absolute; left:0; top:0; }
</style>
<div class="welcomebox2">
  <div class="heading">

</div>
<div class="fluidbox3">
<div class="fadein" >
<?php
$imgurl = 'http://***************.net/images/homepage/';

$queryclient = "SELECT * FROM pictures_homepage";
$rscat = mysql_query($queryclient) or die('Error, query failed');
while($rowcat=mysql_fetch_object($rscat)){
?>
<img src="<?php echo $imgurl; ?><?php echo $rowcat['image']; ?>">

<? } ?>
</div>
</div>  
</div>
</div>
webdzine
Forum Newbie
Posts: 20
Joined: Wed Dec 08, 2010 12:40 am

Re: front page photo slideshow

Post by webdzine »

works i changed
<img src="<?php echo $imgurl; ?><?php echo $rowcat['image']; ?>">
to
<img src="<?php echo $imgurl; ?><?php echo $rowcat->image; ?>">
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: front page photo slideshow

Post by Christopher »

Or you could change mysql_fetch_object() to mysql_fetch_assoc() to get the row as an array. Glad you got it working.
(#10850)
Post Reply