Mark謝謝你
我的程式結構如下
再麻煩大家了
一、autoablums.template{include file="$blogtemplate/header.template"}
<div id="container">
{include_php file="autoalbums.php"}
</div>
{include file="$blogtemplate/footer.template"}
二、autoalbums.php(相片資料程式)<?php
//--取得皆為第一層的主目錄
$selectOptions = "";
$strSQL = "select * from blog_gallery_albums where owner_id='".$_REQUEST['blogId']."' and parent_id='0' and show_album='1'";
$sql_result = mysql_query($strSQL);
while ($row = mysql_fetch_array($sql_result)) {
//echo $row["id"] . "<hr>";
$selectOptions = setSelectOptions($selectOptions, $row["id"], $row["name"]);
$selectOptions = getDetailDocument($row["id"],' ',$selectOptions);
}
//--遞迴function
function getDetailDocument($main_id,$underline,$selectOptions){
$strSQL = "select * from blog_gallery_albums t where t.parent_id='$main_id'";
$sql_result = mysql_query($strSQL);
while ($row = mysql_fetch_array($sql_result)) {
$id = $row["id"];
$temp = $underline . $row["name"];
//echo $temp . "<br>";
$selectOptions = setSelectOptions($selectOptions, $id ,$temp);
//$underline .= '-';
$selectOptions = getDetailDocument($row["id"],$underline,$selectOptions);
}
return $selectOptions;
}
//--串連所有下拉選單內的資料夾
function setSelectOptions($opt, $value ,$name){
if ($_REQUEST['albums'] == $value)
{
$set = "selected";
}else{
$set = "";
}
$selectOptions = $opt. "<option value='$value' $set>$name</option>";
return $selectOptions;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>漂鳥相片欣賞</title>
<script language="javascript">
function changeURL(){
var url;
url = document.goForm.action + "&albums=" + document.goForm.albums.value;
location.href = url;
}
</script>
</head>
<body>
<form name='goForm' action='
http://blog.coa.gov.tw/index.php?blogId=4&op=Template&show=autoalbums' method='post'>
<table width="100%" border="0" cellpadding="1">
<?php
echo "我們的相簿 :"."<select name='albums' onchange='changeURL()'>";
echo "<option value=''>-請選擇相簿-</option>";
echo $selectOptions;
echo "</select>";
if ($_REQUEST['albums']) { //--選擇某相簿
//include('photo_auto.php');
//echo $_REQUEST['get_albums']."<hr>";
include('photo_auto.php');
loadDirectIMG($_REQUEST['blogId'],$_REQUEST['albums']);
}
?>
</table>
</form>
</body>
</html>
三、photo_auto.php(播放程式)<?php
//--取出圖片檔
function loadDirectIMG($owner_id, $album_id){
$Pstr = "select * from blog_gallery_resources where owner_id='$owner_id' and album_id='$album_id'";
//echo $Pstr."<hr>";
$Presult = mysql_query($Pstr);
$x=0;
while($Prow = mysql_fetch_array($Presult, MYSQL_ASSOC)) {
$file_len = strlen($Prow['file_name']);
$start_len = $file_len - 3;
$get_file_name = substr($Prow['file_name'],$start_len,$file_len);
$file_name = "gallery/4/".$Prow['owner_id']."-".$Prow['id'].".".$get_file_name;
$dec_name = ($Prow["description"]<>'')? $Prow["description"]:'未命名';
$p_id[$x] = $Prow["id"];
$p_name[$x] = $file_name;
$p_description[$x] = $dec_name;
$x++;
}
?>
<script language="javascript1.3" type=text/javascript src="js/photo_auto.js"></script>
<script language="javascript1.3">
<?
$imgName = "";
$imgDesc = "";
for($i=0; $i<count($p_id); $i++){
if($i==0){
$imgName = $p_name[$i];
$imgDesc = $p_description[$i];
}else{
$imgName = $imgName . "," . $p_name[$i];
$imgDesc = $imgDesc . "," . $p_description[$i];
}
}
?>
var autoTime = 5000; //照片替換時間(1/1000秒)
var transNum = 23; //預設轉換效果(0-23)
var isReplay = 0; //是否重覆播放(1:是,0:否)
var msgImg = "照片欣賞"; //最先開始的標題
//var imgName = "";
//圖片來源(圖片與圖片間以,隔開)
var imgSrcStr = "<?=$imgName?>";
//圖片名稱(圖片與圖片間以,隔開)
var imgNameStr = "<?=$imgDesc?>";
//預設動作回應名稱(也可換成圖片路徑)
var msgImgStr = "自動播放,播放完畢,下一張,最後一張,上一張,第一張,暫停";
</script>
<script>initImg(); //速度控制項</script>
<script>setImg(); //效果控制項</script>
<script>setAuto(); //播放控制項</script>
<table border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#000000" style="border-collapse:collapse;">
<tr bgcolor="#66CC00">
<td height="41" align="left" valign="top" bgcolor="#ffffff">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="34"><a href="javascript:void(0);" onClick="setAuto();"><img src="imgs/album/auto.png" alt="自動播放" border="0"></a></td>
<td><a href="javascript:void(0);" onClick="backImg();"><img src="imgs/album/back.png" alt="上一張" border="0"></a></td>
<td><a href="javascript:void(0);" onClick="stopImg();"><img src="imgs/album/stop.png" alt="暫停" border="0"></a></td>
<td><a href="javascript:void(0);" onClick="nextImg();"><img src="imgs/album/next.png" alt="下一張" border="0"></a></td>
<td>
<script>setSpeedOpt(); //速度控制項</script>
<script>setTransOpt(); //效果控制項</script>
<script>setReplayOpt(); //播放控制項</script></td>
</tr>
</table> </td>
</tr>
<tr bgcolor="#ffffff">
<td align="center">
<img src="<?=$p_name[0]?>" name="myImageZZ" STYLE="filter:revealtrans(duration=1)" onload="Javascript:resizeImage(this)" >
</tr>
<tr bgcolor="#66CC00">
<td align="center" bgcolor="#ffffff"><div id="myImageTitle"></div></td>
</tr>
</table>
<?
}
?>