i have a problem. i have a folder named jadu, there are various images . i want to show them in the a page. what i did its here

<?
$path = "images";
$dir_handle = @opendir($path) or die("Unable to open $path");
echo "Directory Listing of $path<br/>";
while($file = readdir($dir_handle)) {
if(is_dir($file)) {
continue;
}

else if($file != '.' && $file != '..') {
echo "$file<br/>";
}
}



//closing the directory
//closedir($dir_handle);

?>

above code i use for find the name of image files. now i want to show value of this $file in image Array in following javascript value

<script type="text/javascript">

var mygallery=new simpleGallery({
	wrapperid: "simplegallery1", //ID of main gallery container,
	dimensions: [750, 500], //width/height of gallery in pixels. Should reflect dimensions of the images exactly
	imagearray: [
		["jadu/<? echo "$file<br/>";?>", "jadu/<? echo "$file<br/>";?>", "_new", ""],
		["jadu/img015.jpg", "jadu/img015.jpg", "_new", ""],
		["jadu/img010.jpg", "jadu/img010.jpg", "_new", ""],
		["jadu/img009.jpg", "jadu/img009.jpg", "_new", ""],
		["jadu/img008.jpg", "jadu/img008.jpg", "_new", ""],
		["jadu/img007.jpg", "jadu/img007.jpg", "_new", ""]
	],
	autoplay: [true, 2500, 2], //[auto_play_boolean, delay_btw_slide_millisec, cycles_before_stopping_int]
	persist: false, //remember last viewed slide and recall within same session?
	fadeduration: 500, //transition duration (milliseconds)
	oninit:function(){ //event that fires when gallery has initialized/ ready to run
		//Keyword "this": references current gallery instance (ie: try this.navigate("play/pause"))
	},
	onslide:function(curslide, i){ //event that fires after each slide is shown
		//Keyword "this": references current gallery instance
		//curslide: returns DOM reference to current slide's DIV (ie: try alert(curslide.innerHTML)
		//i: integer reflecting current image within collection being shown (0=1st image, 1=2nd etc)
	}
})

</script>
</head>

<body>
<div id="simplegallery1"></div>

</body>
</html>

Sanj,

In the php while loop,

//-- find
//while($file = readdir($dir_handle)) {
//-- add before
$imageArray = array();

//-- find
//echo "$file<br/>";
//-- replace with
$imageArray[] = sprintf('["%1$s", "%1$s", "_new", ""]', $path.'/'.$file);

In the javascript

//-- delete
/*
imagearray: [
["jadu/<? echo "$file<br/>";?>", "jadu/<? echo "$file<br/>";?>", "_new", ""],
["jadu/img015.jpg", "jadu/img015.jpg", "_new", ""],
["jadu/img010.jpg", "jadu/img010.jpg", "_new", ""],
["jadu/img009.jpg", "jadu/img009.jpg", "_new", ""],
["jadu/img008.jpg", "jadu/img008.jpg", "_new", ""],
["jadu/img007.jpg", "jadu/img007.jpg", "_new", ""]
],
*/
//-- replace with
imagearray: [ <? echo implode(",\n", $imageArray) ?> ],

NOTES:

  • I have used $path (ie. "images") to replace your hard coded "jadu".
  • In your browser, "view source" to see the generated javascript.
  • Not tested - you may need to fine-tune my code

Airshow

This question has already been answered. Start a new discussion instead.