Hi.
I have this slideshow that I want to fetch images that I have stored in my database. My problem is that I don't know how to change the javascript array fetches the images.
The Array lookes this way when it just gets images from a folder.
var Pic = new Array()
Pic[0] = 'Bild1.jpg'
Pic[1] = 'Bild1.jpg'
Pic[2] = 'Bild1.jpg'
Pic[3] = 'Bild1.jpg'
If I want it to get a specific image from my database instead it looks like this
var Pic = new Array()
Pic[0] = '<? echo "slideshow.php?id=1"; ?>'
Pic[1] = '<? echo "slideshow.php?id=2"; ?>'
But this is not what I want. I don't want to specify myself what image to show, but I need some kind of while query that shows all the pictures that I have in the database.
For you to fully understand my question I have pasted the entire code here.
<?
require("dbmanager.php");
//I GATHER THE BINARY DATA FROM THE DB
if($id) {
$query = "select file_data,file_type from bildspel where id=$id";
$result = @MYSQL_QUERY($query);
$data = @MYSQL_RESULT($result,0,"file_data");
$type = @MYSQL_RESULT($result,0,"file_type");
Header( "Content-type: $type");
echo $data;
};
?>
<html>
<head>
<title>Bildspel</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script>
var speed = 1000
// THE ARRAY THAT GETS THE IMAGES
var Pic = new Array()
Pic[0] = '<? echo "slideshow.php?id=1"; ?>'
Pic[1] = '<? echo "slideshow.php?id=2"; ?>'
var t
var j = 0
var p = Pic.length
var preLoad = new Array()
for (i = 0; i < p; i++){
preLoad[i] = new Image()
preLoad[i].src = Pic[i]
}
function runSlideShow(){
document.images.SlideShow.src = preLoad[j].src
j = j + 1
if (j > (p-1)) j=0
t = setTimeout('runSlideShow()', speed)
}
</script>
</head>
<body onload="runSlideShow()">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td id="VU">
<img src="1.gif" name='SlideShow'></td>
</tr>
</table><br><br>
</body>
</html>