www.webdeveloper.com
Results 1 to 2 of 2

Thread: reading files from folder to echo links to jq func

  1. #1
    Join Date
    Mar 2012
    Posts
    48

    Question reading files from folder to echo links to jq func

    im trying to defy as much as pictures that in my gallery folder on my server
    and echo it in jquery function so a gallery slider could show it.. i guess its not possiable or im doing it wrong because its not working..
    i searched the web and noticed that maybe im not doing by the right order..
    i need help please


    Code:
    jQuery(function($){
    				$.comp({
    					slides 					:  	[			// Slideshow Images
    				<?PHP
    						$dirname = "./gallery/"; 
    						$images = scandir($dirname); 
    						foreach($images as $curimg){ 
    							echo "{image : './gallery/$curimg', title : '', thumb : '', url : ''},"; 						      
    						}; 
    					?>
    												]
    					
    				});
    		    });

  2. #2
    Join Date
    Feb 2012
    Posts
    218
    Try this
    Code:
    jQuery(function($){
    	$.comp({
    		slides : [<?PHP
    				$dirname = "./gallery/"; 
    				$images = scandir($dirname); 
    				$i=0;
    				foreach($images as $curimg){
    					if($curimg!='.' and $curimg!='..'){
    						echo ($i?',':'')."\n\t{image : './gallery/$curimg', title : '', thumb : '', url : ''}";
    						$i++;
    					}
    				}; 
    			?>
    
    			]
    		});
    	});
    It outputs something like this.
    Code:
    jQuery(function($){
    	$.comp({
    		slides : [
    				{image : './gallery/index.htm', title : '', thumb : '', url : ''},
    				{image : './gallery/index.php', title : '', thumb : '', url : ''},
    				{image : './gallery/new.jpg', title : '', thumb : '', url : ''}
    			]
    		});
    	});

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles