用XML结合数据库,给服务器减负(2)

来源:互联网 发布:网络终端软件买卖合同 编辑:程序博客网 时间:2024/04/30 01:20

◆songList.asp◆     
<html>
<head>
<title>殷亮的在线播放</title>
<style type="text/css">
<!--
.input
{
background-color: #000000;
border: #000000;
color: #FF9900;
}
-->
</style>
</head>

<body bgcolor="#000000" text="#FF9900">
<% ’’’’’’’’’’连接数据库’’’’’’’’’’’’’
set songCon = Server.CreateObject("ADODB.connection")
conPath = Server.MapPath("songList.mdb")
conStr = "DRIVER={Microsoft Access Driver (*.mdb)}; dbq="
songCon.open(conStr & conPath)
set rs = Server.CreateObject("ADODB.Recordset")
rs.open "Select * from songList",songCon,3,3
%>

<!--动态生成内嵌式XML文档,"在线播放"是根标记-->
<xml id = "xmlFile">
<在线播放>
<%
If not rs.eof then
while not rs.eof
%>
<歌曲>
<歌名><%= trim(rs("song_name")) %></歌名>
<URL><%= trim(rs("song_url")) %></URL>
<演唱者><%= trim(rs("songer")) %></演唱者>
<歌词><%= trim(rs("song_lyrics")) %></歌词>
</歌曲>
<%
rs.movenext
wend
End If
%>
</在线播放>
</xml>
<div id="Layer1" style="position:absolute; width:500px; height:59px; z-index:1; left: 118px; top: 4px;">
 <!--Window Media Player控件-->
 <OBJECT classid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95" width="500" height="43" id="player" style="WIDTH: 500px; HEIGHT: 43px" VIEWASTEXT>
   <PARAM NAME="AudioStream" VALUE="-1">
<PARAM NAME="AutoSize" VALUE="0">
<PARAM NAME="AutoStart" VALUE="-1">
<PARAM NAME="AnimationAtStart" VALUE="-1">
<PARAM NAME="AllowScan" VALUE="-1">
<PARAM NAME="AllowChangeDisplaySize" VALUE="-1">
<PARAM NAME="AutoRewind" VALUE="0">
<PARAM NAME="Balance" VALUE="0">
<PARAM NAME="BaseURL" VALUE="">
<PARAM NAME="BufferingTime" VALUE="5">
<PARAM NAME="CaptioningID" VALUE="">
<PARAM NAME="ClickToPlay" VALUE="-1">
<PARAM NAME="CursorType" VALUE="0">
<PARAM NAME="CurrentPosition" VALUE="-1">
<PARAM NAME="CurrentMarker" VALUE="0">
<PARAM NAME="DefaultFrame" VALUE="">
<PARAM NAME="DisplayBackColor" VALUE="0">
<PARAM NAME="DisplayForeColor" VALUE="16777215">
<PARAM NAME="DisplayMode" VALUE="0">
<PARAM NAME="DisplaySize" VALUE="4">
<PARAM NAME="Enabled" VALUE="-1">
<PARAM NAME="EnableContextMenu" VALUE="-1">
<PARAM NAME="EnablePositionControls" VALUE="-1">
<PARAM NAME="EnableFullScreenControls" VALUE="0">
<PARAM NAME="EnableTracker" VALUE="-1">
<PARAM NAME="Filename" VALUE="">
<PARAM NAME="InvokeURLs" VALUE="-1">
<PARAM NAME="Language" VALUE="-1">
<PARAM NAME="Mute" VALUE="0">
<PARAM NAME="PlayCount" VALUE="1">
<PARAM NAME="PreviewMode" VALUE="0">
<PARAM NAME="Rate" VALUE="1">
<PARAM NAME="SAMILang" VALUE="">
<PARAM NAME="SAMIStyle" VALUE="">
<PARAM NAME="SAMIFileName" VALUE="">
<PARAM NAME="SelectionStart" VALUE="-1">
<PARAM NAME="SelectionEnd" VALUE="-1">
<PARAM NAME="SendOpenStateChangeEvents" VALUE="-1">
<PARAM NAME="SendWarningEvents" VALUE="-1">
<PARAM NAME="SendErrorEvents" VALUE="-1">
<PARAM NAME="SendKeyboardEvents" VALUE="0">
<PARAM NAME="SendMouseClickEvents" VALUE="0">
<PARAM NAME="SendMouseMoveEvents" VALUE="0">
<PARAM NAME="SendPlayStateChangeEvents" VALUE="-1">
<PARAM NAME="ShowCaptioning" VALUE="0">
<PARAM NAME="ShowControls" VALUE="-1">
<PARAM NAME="ShowAudioControls" VALUE="-1">
<PARAM NAME="ShowDisplay" VALUE="0">
<PARAM NAME="ShowGotoBar" VALUE="0">
<PARAM NAME="ShowPositionControls" VALUE="-1">
<PARAM NAME="ShowStatusBar" VALUE="0">
<PARAM NAME="ShowTracker" VALUE="-1">
<PARAM NAME="TransparentAtStart" VALUE="0">
<PARAM NAME="VideoBorderWidth" VALUE="0">
<PARAM NAME="VideoBorderColor" VALUE="0">
<PARAM NAME="VideoBorder3D" VALUE="0">
<PARAM NAME="Volume" VALUE="0">
<PARAM NAME="WindowlessVideo" VALUE="0">
</OBJECT>
</div>


<div id="Layer3" style="position:absolute; width:200px; height:115px; z-index:3; left: 120px; top: 140px;"><img src="/Newhua_Files/Net_pic/2005-11/18/0511181713108032.jpg" width="300" height="170"></div>
<div id="Layer4" style="position:absolute; width:191px; height:54px; z-index:4; left: 430px; top: 199px;">
 <table width="190" height="52" border="1" align="right" bordercolor="#000000" bgcolor="#FF9900">
   <tr>
     <td height="23" valign="bottom">
       <div align="center"></div>
        
       <div align="right">
         <input name="btnPre" type="button" disabled="true" id="btnPre" value="上一首">
       </div></td>
   </tr>
   <tr>
     <td valign="top">
<div align="right">
         <input name="btnNext" type="button" id="btnNext" value="下一首">
       </div></td>
   </tr>
 </table>
</div>
<div id="Layer2" style="position:absolute; width:503px; height:58px; z-index:2; left: 120px; top: 67px;">
 <table width="501" border="1">
   <tr>
     <td width="100"><font color="#FFFFFF" size="2">播放内置歌曲:</font></td>
     <td width="317">
  <SELECT name="list" size="1" id="list" style="WIDTH: 328px; BACKGROUND-COLOR: darkorange">
 <!--用循环来初始化下拉列表-->
         <script language="VBScript">
set xml=xmlFile.recordset
xml.MoveFirst
dim num
for num=0 to xml.RecordCount-1
document.write("<OPTION value="&xml("url")&">"&xml("歌名")&"</OPTION>")
xml.MoveNext
next
xml.MoveFirst
</script>
  </SELECT>
 </td>
     <td width="62"><div align="right">
         <input name="btnLAN" type="button" id="btnLAN" value="播放">
       </div></td>
   </tr>
   <tr>
     <td><font color="#FFFFFF" size="2" >播放网络歌曲:</font></td>
     <td><input name="textURL" type="text" id="textURL" style="WIDTH: 328px; BACKGROUND-COLOR: darkorange;color: #000000;"></td>
     <td><div align="right">
         <input name="btnNET" type="reset" id="btnNET" value="播放">
       </div></td>
   </tr>
 </table>
</div>
<div id="Layer5" style="position:absolute; width:500px; height:20px; z-index:5; left: 120px; top: 320px;">
 <p><font color="#FFFFFF" size="2">正在播放:
   <input name="textSonger" type="text" class="input" id="textSonger" size="15">
   演唱的
   <input name="textSongName" type="text" class="input" id="textSongName" size="35">
   </font></p>
</div>
<div id="Layer6" style="position:absolute; width:500px; height:150px;
z-index:6; left: 120px; top: 349px;">
 <textarea name="area" cols="68" rows="15" id="area"
  style="BORDER-RIGHT: white double; BORDER-TOP: white double;
BORDER-LEFT: white double;COLOR: #000000; DIRECTION: ltr;
BORDER-BOTTOM: white double;BACKGROUND-COLOR: darkorange;
TEXT-ALIGN: left">
 </textarea>
</div>

<!--各按钮的单击事件-->
<script language="VBScript">
sub play()
textSonger.value=xml("演唱者")
textSongName.value=xml("歌名")
textURL.value=""
area.value=xml("歌词")
player.filename=xml("URL")

if xml.AbsolutePosition=xml.recordcount then
btnNext.disabled=true
else
btnNext.disabled=false
end if

if xml.AbsolutePosition=1 then
btnPre.disabled=true
else
btnPre.disabled=false
end if
end sub

sub btnLAN_onclick
xml.MoveFirst
while xml("URL")<>list.value
xml.MoveNext
wend
call play()
end sub

sub btnNET_onclick
player.filename = textURL.value
textSonger.value = ""
textSongName.value = ""
area.value = "自定义网络歌曲"
end sub

sub btnPre_onclick
xml.MovePrevious
list.selectedIndex = list.selectedIndex - 1
call play()
end sub

sub btnNext_onclick
xml.MoveNext
list.selectedIndex = list.selectedIndex + 1
call play()
end sub
</script>
</body>
</html>
现在,你知道怎么给服务器减负了吗?

(完)