I am very new to php. I am using a php code to use a image directory to fade image in and out. I need to be able to use the same code but for different directories on the same page.
<?
// Global Variables
$image_dir = "$_SERVER[DOCUMENT_ROOT]/trinity_cyclery2011/bmx/images/mirraco"; // directory on server
$image_relative_path = '/trinity_cyclery2011/bmx/images/mirraco'; // path to images relative to script
$file_types = array('jpg','jpeg','gif','png');
$image_time = '4000'; // seconds each image will display (4000 = 4 seconds)
if($handle = opendir($image_dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$ext_bits = explode(".",$file); // finds file extensions
foreach($ext_bits as $key => $value){
if(in_array($value,$file_types)){
$image_rotation .= '<li><img src="'.$image_relative_path.'/'.$file.'"></li>';
}
}
}
}
closedir($handle);
}
?>
<?
// Global Variables
$image_dir = "$_SERVER[DOCUMENT_ROOT]/trinity_cyclery2011/bmx/images/fitbike"; // directory on server
$image_relative_path = '/trinity_cyclery2011/bmx/images/fitbike'; // path to images relative to script
$file_types = array('jpg','jpeg','gif','png');
$image_time = '4000'; // seconds each image will display (4000 = 4 seconds)
if($handle = opendir($image_dir)) {
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") {
$ext_bits = explode(".",$file); // finds file extensions
foreach($ext_bits as $key => $value){
if(in_array($value,$file_types)){
$image_rotation_fit .= '<li><img src="'.$image_relative_path.'/'.$file.'"></li>';
}
}
}
}
closedir($handle);
}
?>
and this goes in the document.
<script>
$(document).ready(function() {
$('#image_rotate').innerfade({
speed: 'slow',
timeout: 4000,
type: 'sequence',
containerheight: '220px'
});
});
</script>
<ul id="image_rotate" style="list-style: none;">
<?= $image_rotation; ?>
</ul>
<script>
$(document).ready(function() {
$('#image_rotate').innerfade({
speed: 'slow',
timeout: 4000,
type: 'sequence',
containerheight: '220px'
});
});
</script>
<ul id="image_rotate" style="list-style: none;">
<?= $image_rotation_fit; ?>
</ul>
any help will be greatly appreciated. Thanks