I made a mysql table on my website with backend that allows me to upload images of affiliate companies i deal with. I used this script and it works. I now have need to add URL to these.
As you can see i select the directory the iamges are in as the can be different for each page loaded.
This works:
<script language="JavaScript">
// configuration structure
var A_TPL = {
// randomize the array each time page loads
'random' : false,
// number of transparency changes during the transition
// increase for smoother transition, reduce for less CPU usage
'steps' : 20,
// transition duration in seconds
'transtime': .5,
// slide time in seconds
'slidetime': 1,
// width of the slide (optional)
'width' : 400,
// height of the slide (optional)
'height': 300,
// alt text for the image (optional)
'alt' : 'Website name',
// css class assigned to the slide <img> (optional)
'css' : ''
};
// list of images to display
var A_ITEMS = [<?php
//EXTRACT MYSQL PATH DATA
$extract = mysql_query("SELECT * FROM images");
while ($row = mysql_fetch_assoc($extract))
{
$directory = $row['imagedir'];
}
$s_path = ($directory);
$a_types = array ('jpg', 'jpeg');
$a_images = array ();
$h_dir = opendir($s_path);
while ($s_file = readdir($h_dir)) {
$s_type = strtolower(substr(strrchr($s_file, '.'), 1));
if (in_array($s_type, $a_types))
array_push($a_images, "\n\t\t'$s_path$s_file'");
}
closedir($h_dir);
sort($a_images);
echo join(',', $a_images);
?>
];
// fader initialization
var mySlideShow = new tFader (A_ITEMS, A_TPL);
</script>
as you can see the var A_ITEMS gets the image names from the directory it finds in mysql.
i now want to try get the image directory, image name and url from mysql, the table is set up but im new to javasrcipt and it gives me different errors no matter what i try and do.
Note the lines with //
<script type="text/javascript">
var mygallery=new fadeSlideShow({
wrapperid: "fadeshow1", //ID of blank DIV on page to house Slideshow
dimensions: [250, 100], //width/height of gallery in pixels. Should reflect dimensions of largest image
imagearray: [
var A_ITEMS = [<?php
//EXTRACT MYSQL DATA
$extract = mysql_query("SELECT * FROM images");
while ($row = mysql_fetch_assoc($extract))
{
$imagefolder = $row['imagedir'];
$imagefilename = $row['imagefile'];
$imageurl = $row['imageurl'];
echo ('"['$imagefolder'/,'$imagefilename'", "'$imageurl'", "_new"]'
//["directory/imagename.jpg", "http://www.website.com/", "_new"],
//PLEASE NOTE: Do not add trailing comma after very last image element!
}
?>
],
displaymode: {type:'auto', pause:2500, cycles:0, wraparound:false},
persist: false, //remember last viewed slide and recall within same session?
fadeduration: 500, //transition duration (milliseconds)
descreveal: "ondemand",
togglerid: ""
})
</script>
you wil note these rows:
echo ('"'
im tryong to make the echo give data like row below:
//["directory/imagename.jpg", "http://www.website.com/", "_new"],
//PLEASE NOTE: Do not add trailing comma after very last image element!
Thats where i get stuck ... ho can i use the values from MYSQL and the trailing comma ?
I know its something stupid im doing