Do connection with database itself then do.........
Table name >> cms_banner_master with this fields id,imagenm,onclick_url
//http://websitename/
//uploadfiles Stored images
$imageDir = '/websitename/uploadfiles/';
define('SERVERPATH', $_SERVER['DOCUMENT_ROOT'].$imageDir);
define('HTTPPATH', 'http://'.$_SERVER['HTTP_HOST'].$imageDir);
$array=array();
$linkarray=array();
$query=getdata("select imagenm,onclick_url from cms_banner_master" );
while($rs=mysql_fetch_array($query))
{
$image=$rs['imagenm'];
$link=$rs['onclick_url'];
$array[]=$rs['imagenm'];
$linkarray[]=$rs['onclick_url'];
}
$dir = opendir(SERVERPATH);
$javascriptArray = null;
$JLINK=null;
$i = null;
foreach($array as $imagevalue)
{
if (eregi('\.(gif|png|jpg)$',$imagevalue)){
$javascriptArray .= $i.'"'.HTTPPATH.$imagevalue.'"';
$i = ',';
}
}
foreach($linkarray as $linkvalue)
{
$JLINK.=$linkvalue.',';
}
$JLINK=substr($JLINK, 0, -1);
closedir($dir);
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>Rotate Images</title>
<script type="text/javascript">
function rotateImage(){
var linkImages='<?php echo $JLINK;?>'.split(',');
rotatingImages = new Array(<?php echo $javascriptArray; ?>);
imageCount = rotatingImages.length;
firstTime = true;
duration = "3"; //seconds
// Cycle through images sequencially starting with a random image
// Do not update the image if loading is not yet completed
if (document.getElementById('rotatingImage').complete || firstTime){
if (firstTime) {
thisImage = Math.floor((Math.random() * imageCount))
firstTime = false
}else{
thisImage++
if (thisImage == imageCount) {
thisImage = 0
}
}
document.getElementById('rotatingImage').src = rotatingImages[thisImage]
for (var k=0;k<linkImages.length;k++)
{
var a=document.getElementById('href').href=linkImages[thisImage];
}
setTimeout("rotateImage()", duration * 1000)
}
}
</script>
</head>
<body>
<div id="slideshow">
<a id="href" target="_blank"><img height="186" width="308" id="rotatingImage" alt="" /></a>
</div>
<script type="text/javascript">
rotateImage();
</script>
</body>
</html>
Table name >> cms_banner_master with this fields id,imagenm,onclick_url
//http://websitename/
//uploadfiles Stored images
$imageDir = '/websitename/uploadfiles/';
define('SERVERPATH', $_SERVER['DOCUMENT_ROOT'].$imageDir);
define('HTTPPATH', 'http://'.$_SERVER['HTTP_HOST'].$imageDir);
$array=array();
$linkarray=array();
$query=getdata("select imagenm,onclick_url from cms_banner_master" );
while($rs=mysql_fetch_array($query))
{
$image=$rs['imagenm'];
$link=$rs['onclick_url'];
$array[]=$rs['imagenm'];
$linkarray[]=$rs['onclick_url'];
}
$dir = opendir(SERVERPATH);
$javascriptArray = null;
$JLINK=null;
$i = null;
foreach($array as $imagevalue)
{
if (eregi('\.(gif|png|jpg)$',$imagevalue)){
$javascriptArray .= $i.'"'.HTTPPATH.$imagevalue.'"';
$i = ',';
}
}
foreach($linkarray as $linkvalue)
{
$JLINK.=$linkvalue.',';
}
$JLINK=substr($JLINK, 0, -1);
closedir($dir);
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<title>Rotate Images</title>
<script type="text/javascript">
function rotateImage(){
var linkImages='<?php echo $JLINK;?>'.split(',');
rotatingImages = new Array(<?php echo $javascriptArray; ?>);
imageCount = rotatingImages.length;
firstTime = true;
duration = "3"; //seconds
// Cycle through images sequencially starting with a random image
// Do not update the image if loading is not yet completed
if (document.getElementById('rotatingImage').complete || firstTime){
if (firstTime) {
thisImage = Math.floor((Math.random() * imageCount))
firstTime = false
}else{
thisImage++
if (thisImage == imageCount) {
thisImage = 0
}
}
document.getElementById('rotatingImage').src = rotatingImages[thisImage]
for (var k=0;k<linkImages.length;k++)
{
var a=document.getElementById('href').href=linkImages[thisImage];
}
setTimeout("rotateImage()", duration * 1000)
}
}
</script>
</head>
<body>
<div id="slideshow">
<a id="href" target="_blank"><img height="186" width="308" id="rotatingImage" alt="" /></a>
</div>
<script type="text/javascript">
rotateImage();
</script>
</body>
</html>
Looking for top-notch Laravel development services? Look no further than Connect Infosoft Technologies. We are a leading software development company with a strong expertise in Laravel framework. Our team of experienced developers excels in delivering high-quality and scalable web applications using Laravel. Looking for Laravel Dev Team in India
ReplyDelete