Forum Moderators: coopster

Message Too Old, No Replies

Dynamic slideshow + mysql and php

how to display images saved in mysql to a slideshow.

         

zara1

10:01 am on Jul 21, 2008 (gmt 0)

10+ Year Member



This my first post. I was hoping you guys can help me, I hope I posted to the right forum! I have the the javscript code below that does a imageslideshow which works fine. I have my images saved in mysql as blob, how would I go about populating the javascript array below with the images from mysql. I understand that it is possible to mix php + javscript, but not sure how go about doing it. Any help will much apperciated.

<html>
<head>
<title>slideshow<title>
<script language="JavaScript">
var present_slide=0;

var images = new Array(''http://www.anyserver/image//2435.jpg'',
''http://www.anyserver/image//2436.jpg'',
''http://www.anyserver/image//2437.jpg'',
''http://www.anyserver/image//2438.jpg'',
''http://www.anyserver/image//2439.jpg'',
''http://www.anyserver/image//2440.jpg'',
''http://www.anyserver/image//2441.jpg'',
''http://www.anyserver/image//2442.jpg'');

objImage = new Image();

function download(img_src){
// preload the image file
objImage.src=images[img_src];
}

function displaynext(shift){
present_slide=present_slide + shift;

if(images.length > present_slide && present_slide >= 0){
document.images[''im''].src = images[present_slide];

var next_slide=present_slide + 1;
download(next_slide); // Download the next image
}

if(present_slide+1 >= images.length ){
document.f1.Next.style.visibility = "hidden";
present_slide=images.length-1;
}else{document.f1.Next.style.visibility = "visible";}

if(present_slide<=0 ){
document.f1.Prev.style.visibility = "hidden";
present_slide=0;
}else{
document.f1.Prev.style.visibility = "visible";}
}
</script>
</head>
<body onLoad="displaynext(0)">

<form name="f1" method=post action=''''>

<img name="im" ></a><br>
<input type="button" name="Prev" value=" << " onClick="displaynext(-1);">
<input type="button" name="Next" value=" >> " onClick="displaynext(1);">
</form>
</body>
</html>

NomikOS

8:07 pm on Jul 21, 2008 (gmt 0)

10+ Year Member



to mix php + javascript:

<script language="javascript">
if (parent.location != window.location)
{
location.replace('http://domain.com<?php echo $_SERVER['REQUEST_URI']; ?>');
}
<?php
if ($OK)
echo "var variable= value";
?>
</script>

malcolmcroucher

7:12 am on Jul 22, 2008 (gmt 0)

10+ Year Member



Why dont you try [slide.com...] ?

[edited by: eelixduppy at 3:06 pm (utc) on July 22, 2008]
[edit reason] linked up [/edit]

zara1

8:48 am on Jul 22, 2008 (gmt 0)

10+ Year Member



this not quite what I had in mind. can anyone then tell me how to go about populating javascript array with resultset from mysql query.

NomikOS

12:03 am on Jul 23, 2008 (gmt 0)

10+ Year Member



something like this: 

echo "var myArray = Array();";
$this->query($aQuery);
while ($this->nextRow())
{
echo "myArray[] = {$this->row['data']}\n";
}


looks dirty, but that's the way.