php圖片流顯示
<?php
$dir = "./images/"; //要獲取的目錄
echo "********** 獲取目錄下所有文件和文件夾 ***********<hr/>";
//先判斷指定的路徑是不是一個文件夾
if (is_dir($dir)){
if ($dh = opendir($dir)){
while (($file = readdir($dh))!= false){
//文件名的全路徑 包含文件名
$filePath = $dir.$file;
echo "<img src='".$filePath."'/>";
}
closedir($dh);
}
}
?>
『貳』 php如何讓資料庫中的圖片在網頁首頁滾動顯示
可以用無縫圖片滾動效果 如:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
* { margin: 0; padding: 0;}
body{ background-color:#1B1B1B}
#div1{ width: 800px; height: 150px; position: relative; margin: 100px auto;overflow: hidden;}
#div1 ul { width: 800px; height: 150px; position: relative; }
#div1 ul li { height: 150px; float: left; list-style: none; padding-right:20px;}
#div1 ul li img { width: 200px; height: 150px; display: inline-block;}
a{ color: #B4B4B4; }
</style>
<script type="text/javascript">
window.onload=function(){
var odiv = document.getElementById('div1');
var oul = odiv.getElementsByTagName('ul')[0];
var ali = oul.getElementsByTagName('li');
var spa = -2;
oul.innerHTML=oul.innerHTML+oul.innerHTML;
oul.style.width=ali[0].offsetWidth*ali.length+'px';
function move(){
if(oul.offsetLeft<-oul.offsetWidth/2){
oul.style.left='0';
}
if(oul.offsetLeft>0){
oul.style.left=-oul.offsetWidth/2+'px'
}
oul.style.left=oul.offsetLeft+spa+'px';
}
var timer = setInterval(move,30)
odiv.onmousemove=function(){clearInterval(timer);}
odiv.onmouseout=function(){timer = setInterval(move,30)};
document.getElementsByTagName('a')[0].onclick = function(){
spa=-2;
}
document.getElementsByTagName('a')[1].onclick = function(){
spa=2;
}
}
</script>
</head>
<body>
<a href="#" style=" display: block; margin:0 auto; width: 50px;">向左走</a>
<a href="#" style=" display: block; margin:0 auto; width: 50px;">向右走</a>
<div id="div1">
<ul>
<li><img src="img/1.jpg"/></li>
<li><img src="img/2.jpg"/></li>
<li><img src="img/3.jpg"/></li>
<li><img src="img/4.jpg"/></li>
</ul>
</div>
</body>
</html>
『叄』 php中如何讓圖片顯示出來,現在可以從資料庫中讀出圖片路徑
$conn=mysql_connect("localhost","root","");//ip用戶名密碼
mysql_select_db("sitecms",$conn);//資料庫名
mysql_query("setnames'utf8'");//utf-8格式
$sql="selecturlfromlinkwherelid=3";
$result=mysql_query($sql,$conn);
while($row=mysql_fetch_array($result)){
echo"<imgsrc='".$row['url']."'/>";
}
『肆』 php中如何調用資料庫中的圖片並且顯示到頁面
php是採用二進制形式存儲圖片及讀取顯示的,首先通過代碼創建數據表,然後上傳圖片伺服器再通過瀏覽器顯示,具體編程代碼舉例:
1、首先需要創建數據表,具體代碼如下圖所示。