unable to add php image rotater in html file
Posted: Thu Sep 24, 2009 12:59 pm
Hi All,
I am new to php . I have written a php code to display an image. This imgage change on every day (sun, mon)
this is working fine but when I put in another html file using the propert backgrund-image: url(....) it does't work . I using localost for displaying php files:
here are file code
read.php
<?php
$string =array();
$filePath='./photos';
$dir = opendir($filePath);
while ($file = readdir($dir)) {
if (eregi("\.png",$file) || eregi("\.jpg",$file) || eregi("\.gif",$file) ) {
$string[] = $file;
}
}
/* $n=rand(0, sizeof($string)-1);
echo $n; */
$n1=idate("w");
echo $n1;
echo "<img src='$filePath/$string[$n1]' />";
?>
index.html ( the html code in problem)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
#image {width:100px;height:100px;background-color:red;background-image: url(http://localhost/website/alpha/read.php);}
</style>
<title>Welcome to Children’s Yoga!</title>
</head>
<body>
<div id="image"> I want to display image here </div>
</body>
</html>
Thanks
Gauri
I am new to php . I have written a php code to display an image. This imgage change on every day (sun, mon)
this is working fine but when I put in another html file using the propert backgrund-image: url(....) it does't work . I using localost for displaying php files:
here are file code
read.php
<?php
$string =array();
$filePath='./photos';
$dir = opendir($filePath);
while ($file = readdir($dir)) {
if (eregi("\.png",$file) || eregi("\.jpg",$file) || eregi("\.gif",$file) ) {
$string[] = $file;
}
}
/* $n=rand(0, sizeof($string)-1);
echo $n; */
$n1=idate("w");
echo $n1;
echo "<img src='$filePath/$string[$n1]' />";
?>
index.html ( the html code in problem)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
#image {width:100px;height:100px;background-color:red;background-image: url(http://localhost/website/alpha/read.php);}
</style>
<title>Welcome to Children’s Yoga!</title>
</head>
<body>
<div id="image"> I want to display image here </div>
</body>
</html>
Thanks
Gauri