Page 2 of 2

Re: Image slide show with PHP and MYSQL

Posted: Wed Jan 25, 2012 7:40 pm
by Celauran
I can't see the head of the document. Did you remember to include jQuery?

Working code:

Code: Select all

<!DOCTYPE html>
<html>
    <head>
        <title>jQuery Slideshow</title>
        <script type="text/javascript" src="jquery.js"></script>
        <script type="text/javascript">
        $(document).ready(function(){
            $('.fadein img:gt(0)').hide();
            setInterval(function(){
              $('.fadein :first-child').fadeOut()
                 .next('img').fadeIn()
                 .end().appendTo('.fadein');}, 
              3000);
        });
        </script>
        <style type="text/css">
        .fadein { position:relative; width:500px; height:332px; }
        .fadein img { position:absolute; left:0; top:0; }
        </style>
    </head>
    <body>
        <div class="fadein">
            <img src="http://farm3.static.flickr.com/2610/4148988872_990b6da667.jpg" />
            <img src="http://farm3.static.flickr.com/2597/4121218611_040cd7b3f2.jpg" />
            <img src="http://farm3.static.flickr.com/2531/4121218751_ac8bf49d5d.jpg" />
        </div>
    </body>
</html>

Re: Image slide show with PHP and MYSQL

Posted: Thu Jan 26, 2012 6:15 am
by crf121359
I have tried it with html tags and heads and body etc and still doesn't work. in fact the code that you sent me above doesn't work either! is there something wrong with jquery?

Re: Image slide show with PHP and MYSQL

Posted: Thu Jan 26, 2012 7:09 am
by Celauran
Maybe there's something wrong with your copy of jQuery. The code I posted above works just fine.

Re: Image slide show with PHP and MYSQL

Posted: Thu Jan 26, 2012 7:14 am
by crf121359
i just copied and pasted your code in a blank page and uploaded it on my live server though! where did you get your copy of jquery?

Re: Image slide show with PHP and MYSQL

Posted: Thu Jan 26, 2012 7:33 am
by Celauran

Re: Image slide show with PHP and MYSQL

Posted: Thu Jan 26, 2012 9:45 am
by crf121359
Thanks buddy. I used that jQuery script from the link that you sent and now your example works BUT my script doesn't still work for some reason!

Here is my current code:

Code: Select all

<!DOCTYPE html>
<html>
    <head>
        <title>jQuery Slideshow</title>
        <script type="text/javascript" src="jquery-1.7.1.min.js"></script>
        <script type="text/javascript">
        $(document).ready(function(){
            $('.fadein img:gt(0)').hide();
            setInterval(function(){
              $('.fadein :first-child').fadeOut()
                 .next('img').fadeIn()
                 .end().appendTo('.fadein');},
              3000);
        });
        </script>
        <style type="text/css">
        .fadein { position:relative; width:500px; height:332px; }
        .fadein img { position:absolute; left:0; top:0; }
        </style>
</head>
   <body>
     <div class="fadein">
<?php
// Connects to your Database
mysql_connect("localhost", "databaseusername", "password") or die(mysql_error()) ;
mysql_select_db("databse") or die(mysql_error()) ;

//Retrieves data from MySQL
$data = mysql_query("SELECT * FROM employees LIMIT 3") or die(mysql_error());

echo "<div class=\"fadein\">";
while($info = mysql_fetch_array( $data ))
{
    //Outputs the image and other data
    echo "<img src=images22/{$info['uploaded']} />";
}
echo "</div>";
?>
</body>
</html>
What am I doing wrong? am I missing something?

Re: Image slide show with PHP and MYSQL

Posted: Thu Jan 26, 2012 9:48 am
by Celauran
It looks OK. Can you post the final HTML?

Re: Image slide show with PHP and MYSQL

Posted: Thu Jan 26, 2012 9:55 am
by crf121359

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>jQuery Slideshow</title>
        <script type="text/javascript" src="jquery-1.7.1.min.js"></script>
        <script type="text/javascript">
        $(document).ready(function(){
            $('.fadein img:gt(0)').hide();
            setInterval(function(){
              $('.fadein :first-child').fadeOut()
                 .next('img').fadeIn()
                 .end().appendTo('.fadein');},
              3000);
        });
        </script>
        <style type="text/css">
        .fadein { position:relative; width:500px; height:332px; }
        .fadein img { position:absolute; left:0; top:0; }
        </style>
</head>
   <body>
     <div class="fadein">
<?php
// Connects to your Database
mysql_connect("localhost", "databseusername", "password") or die(mysql_error()) ;
mysql_select_db("database") or die(mysql_error()) ;

//Retrieves data from MySQL
$data = mysql_query("SELECT * FROM employees LIMIT 3") or die(mysql_error());

echo "<div class=\"fadein\">";
while($info = mysql_fetch_array( $data ))
{
    //Outputs the image and other data
    echo "<img src=images22/{$info['uploaded']} />";
}
echo "</div>";
?>
</body>
</html>

Re: Image slide show with PHP and MYSQL

Posted: Thu Jan 26, 2012 9:59 am
by crf121359
The code above crashes my browser for some strange reason!! it also puts the images on the top of eachother and it doesn't remove the last image before showing the the next image and then it will crash my browser.

Re: Image slide show with PHP and MYSQL

Posted: Thu Jan 26, 2012 10:10 am
by Celauran
You've got nested <div class="fadein"> which could be problematic. I'd still like to see the final rendered HTML, though I understand that may be tough if your browser keeps crashing.

Re: Image slide show with PHP and MYSQL

Posted: Thu Jan 26, 2012 10:17 am
by crf121359
I tried everything. I even put the php part outside of html body and still doesn't work!!! I guess I'm gonna have to hire someone to get this done. Thanks ever so much for your time and help.