php - Code not Working : Photo Swap using Jquery -


i try page like.it replaces images every 10 seconds,using jquery.

i put code below.(source code: http://blog.tremaynechrist.co.uk/post/2011/04/17/photofy-new-animated-photo-swap-plugin-for-jquery.aspx)

<script type="text/javascript">       $(document).ready(function () {           var getdata = setinterval(function()          {              //$('#displaydata').load('anyphpfile.php?randval='+ math.random());            var myoptions = {             url:'anyphpfile.php?randval='+ math.random(),              success: function(data) {                  $('#postdiv').html(data);             },             error:  function(xmlhttprequest, textstatus, errorthrown) {                   alert(xmlhttprequest);                   alert(textstatus);                   alert(errorthrown);              }                        }           $("#facesphotowrapper").photofy(myoptions);           }, 1000);       });       var imagelist = []; /*imagelist = ['http://blog.tremaynechrist.co.uk/downloads/faces/1.jpg','http://blog.tremaynechrist.co.uk/downloads/faces/2.jpg',             'http://blog.tremaynechrist.co.uk/downloads/faces/3.jpg','http://blog.tremaynechrist.co.uk/downloads/faces/4.jpg',             'http://blog.tremaynechrist.co.uk/downloads/faces/5.jpg','http://blog.tremaynechrist.co.uk/downloads/faces/6.jpg',             'http://blog.tremaynechrist.co.uk/downloads/faces/7.jpg','http://blog.tremaynechrist.co.uk/downloads/faces/8.jpg',             'http://blog.tremaynechrist.co.uk/downloads/faces/9.jpg','http://blog.tremaynechrist.co.uk/downloads/faces/10.jpg' ];*/ </script> 

$dbhost2 = "localhost"; $dbuser2 = "root"; $dbpassword2 = ""; $db2 = "extjs_image"; $connection2 = mysql_connect($dbhost2,$dbuser2,$dbpassword2) or die (mysql_error()); mysql_select_db($db2,$connection2);     $qry = "select * tbl_images order rand() limit 5 ";          $result = mysql_query($qry);  $myarray=array(); $str="[";  while ($row = mysql_fetch_assoc($result)){       $str .= "'images/".$row['image']."',"; } $str = substr($str,0,-1); $str .="]"; /*['images/1_01.jpg','images/1_21.jpg','images/1_11.jpg','images/1_10.jpg','images/1_25.jpg'['images/1_01.jpg','images/1_21.jpg','images/1_11.jpg','images/1_10.jpg','images/1_25.jpg'] */ 

?>

photofy isn't designed real-time image updates. because never stay on page large amounts of time, images change on page load. i'm interested add option photofy later down line.

to effect of this, submit greater amount of images want display. in imagelist, submit 27 images example. limit shown setting imagecount 9.

you can still randomise images sent photofy on every page load. php code return javascript file containing array.

var imagelist = ['/downloads/faces/1.jpg','/downloads/faces/2.jpg','/downloads/faces/3.jpg']; //etc 

so do...

<div id="photofywrapper"></div>  <script type="text/javascript" src="imagelistgenerator.php"></script> <script type="text/javascript"> var myoptions = { images: imagelist, imagecount: 9 }; $("#photofywrapper").photofy(myoptions); </script> 

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -