묻고답하기
이미지 랜덤 함수 안먹힙니다!!
2014.05.29 19:25
<?
$aisicnt = rand(1, 4);
switch($aisicnt) {
case (1):$aisimemo="<img src=ima/title_01.jpg>";break;
case (2):$aisimemo="<img src=ima/title_02.jpg>";break;
case (3):$aisimemo="<img src=ima/title_03.jpg>";break;
case (4):$aisimemo="<img src=ima/title_04.jpg>";break;
}
?>
<style type="text/css">
<!--
body, table, tr, td, select,input,div,form,textarea {font-family:"돋움체", Seoul, verdana; font-size:9pt; line-height:150%}
A:link {text-decoration:none; color:#000000}
A:visited {text-decoration:none; color:#000000}
A:active {text-decoration:none; color:#000000}
A:hover {text-decoration:none; color:#529CFF}
BODY { background:#FFFFFF url();}
-->
</style>
<!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" />
<title>기획사업::한국농아인협회 대구광역시협회</title>
<SCRIPT language=JavaScript src="obj.visibility=v; }
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function show_layer(a){
target = document.getElementById(a);
if(target.style.visibility!='visible'){
divShow(a);
}else{
divhide(a);
}
}//갤러리 서브 메뉴 숨김/펼치기 여부 확인
function gallery_xy(){
document.getElementById("gallery_thump").style.left = _x + 50;
document.getElementById("gallery_thump").style.top = _y - 150;
} //갤러리명 onmousemove시 대문 이미지 좌표 이동
function gallery_view(str){
var text;
text ='<table align="center" border="0" cellpadding="0" cellspacing="1" bgcolor="#cccccc" style="font-size:9pt; border-width:0; border-color:black; border-style:solid; word-break:break-all;" class=shadow>';
text += '<tr ><td align=center><img onerror=\'this.src="http://wstatic.dcinside.com/thum/noimg.gif"\' src=http://daegu-deaf.or.kr/ima/images/k/'+str+'.gif width=500 height=270 border=0></td></tr></table>';
gallery_thump.innerHTML=text ;
}//갤러리 대문 스크립트
function gallery_hide(){
gallery_thump.innerHTML=''
}
</script>
<script language="javascript">
<!--
function showaddservice(){
if(document.all){
document.all.addservice.style.posTop=132
document.all.addservice.style.posLeft=15
document.all.addservice.style.visibility="visible"
}
if (document.layers){
document.addservice.top=138
document.addservice.Left=15
document.addservice.visibility="visible"
}
var timer =setTimeout("hideaddservice()",5000)
}
function hideaddservice(){
if (document.all){document.all.addservice.style.visibility="hidden"}
if (document.layers){document.addservice.style.visibility="hidden"}
var timer =setTimeout("showaddservice()",1000000)
}
//-->
</script>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<script type="text/javascript">
<!--
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src = x.oSrc;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc = x.src; x.src = a[i+2];}
}
//-->
</script>
<script language="JavaScript">
var aName = navigator.appName;
var aVer = navigator.appVersion.substring(navigator.appVersion.indexOf(';')+2, navigator.appVersion.lastIndexOf(';'));
var aVer_fw = aVer.substring(0, aVer.indexOf(' '));
var aVer_bw = aVer.substring(aVer.indexOf(' ')+1);
</script>
<SCRIPT language=javascript>
<!--
var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
function getRef(id)
{
if (isDOM) return document.getElementById(id);
if (isIE4) return document.all[id];
if (isNS4) return document.layers[id];
}
var isNS = navigator.appName == "Netscape";
function moveRightEdge()
{
var yMenuFrom, yMenuTo, yOffset, timeoutNextCheck, xPos;
if (isNS4)
{
yMenuFrom = divMenu.top;
yMenuTo = windows.pageYOffset; // 위쪽 위치
xPos = windows.pageXOffset;
}
else if (isDOM)
{
yMenuFrom = parseInt (divMenu.style.top, 0);
if( aVer_bw >= 5.5 )
yMenuTo = (isNS ? window.pageYOffset : document.body.scrollTop) + 580; // 위쪽 위치
else
yMenuTo = (isNS ? window.pageYOffset : document.body.scrollTop) +580; // 위쪽 위치
xPos = (isNS ? window.pageXOffset : document.body.scrollWidth) + 0;
}
timeoutNextCheck = 500;
if (isNS4)
divMenu.left = 0;
divMenu.style.left = 0;
if (yMenuFrom != yMenuTo)
{
yOffset = Math.ceil(Math.abs(yMenuTo - yMenuFrom) / 20);
if (yMenuTo < yMenuFrom)
yOffset = -yOffset;
if (isNS4)
divMenu.top += yOffset;
else if (isDOM)
divMenu.style.top = parseInt (divMenu.style.top, 10) + yOffset;
timeoutNextCheck = 10;
}
setTimeout ("moveRightEdge()", timeoutNextCheck);
}
-->
</SCRIPT>
<script language='javascript' src='gotop.js'></script>
</head>
<body bgcolor="white" text="black" link="blue" vlink="black" alink="black" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" style="background-image:url('/ima/bg_01.png'); background-repeat:repeat-x bottom; overflow:scroll;"onload="showaddservice();MM_preloadImages('menus/menu01_01b.gif','menus/menu01_02b.gif','menus/menu01_03b.gif','menus/menu01_04b.gif','menus/menu01_05b.gif')">
<div id="addservice" style="position:absolute;visibility:hidden;width=200"><img src="menus/busy.gif"></div>
<div style="position:absolute; left:350px; top:10px" id="head">
<!--로그인/회원가입메뉴//-->
<table border="0" cellpadding="0" cellspacing="0" >
<tr>
<td align='right' width="300"><img class="zbxe_widget_output" widget="login_info" skin="default" /></td>
<td align='center' width="70"><a href="</tr>
</table>
</div>
<table width=100% border="0" cellpadding="0" cellspacing="0" background="ima/bg_02.png">
<tr>
<td colspan="2"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="900" height="120">
<param name=movie value="/ima/main_menu1.swf" />
<param name=wmode value="transparent" />
<param name="play" value="true" />
<param name="loop" value="true" />
<param name=quality value="high" />
<embed src="/ima/main_menu1.swf" quality=high pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" wmode="transparent" width="900" height="120"> </embed>
</object></td>
</tr></table>
<table width="915" border="0" cellpadding="0" cellspacing="0">
<tr>
<td> </td>
<td height="200"><img src="menus/menu02.jpg" /></td>
<td height="200"><img src="<?=$aisimemo?>" /></td>
</tr>
<tr>
<td> </td>
<td><a href="/?mid=kbusy" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image1','','menus/menu02_01b.gif',1)"><img src="menus/menu02_01.gif" name="Image1" width="200" height="24" border="0" id="Image1" /></a></td>
<td width="700" rowspan="10"><table id="Table_01" width="700" height="3050" border="0" cellpadding="0" cellspacing="0">
<!--기획사업 중간 이미지배경-->
<tr>
<td>
<img src="ima/images/k/kbusy.gif" width="700" height="3050" alt=""></td>
</tr>
</table></td>
</tr>
<tr>
<td> </td>
<td><a href="/?mid=suhwa" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image2','','menus/menu02_02b.gif',1)"><img src="menus/menu02_02.gif" name="Image2" width="200" height="23" border="0" id="Image2" /></a></td>
</tr>
<tr>
<td> </td>
<td><a href="/?mid=book" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image3','','menus/menu02_03b.gif',1)"><img src="menus/menu02_03.gif" name="Image3" width="200" height="23" border="0" id="Image3" /></a></td>
</tr>
<tr>
<td> </td>
<td><a href="/?mid=job" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image4','','menus/menu02_04b.gif',1)"><img src="menus/menu02_04.gif" name="Image4" width="200" height="23" border="0" id="Image4" /></a></td>
</tr>
<tr>
<td> </td>
<td><a href="/?mid=info" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image5','','menus/menu02_05b.gif',1)"><img src="menus/menu02_05.gif" name="Image5" width="200" height="23" border="0" id="Image5" /></a></td>
</tr>
<tr>
<td> </td>
<td><a href="/?mid=jojik" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image6','','menus/menu02_06b.gif',1)"><img src="menus/menu02_06.gif" name="Image6" width="200" height="23" border="0" id="Image6" /></a></td>
</tr>
<tr>
<td> </td>
<td><a href="/?mid=kita" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image7','','menus/menu02_07b.gif',1)"><img src="menus/menu02_07.gif" name="Image7" width="200" height="23" border="0" id="Image7" /></a></td>
</tr>
<tr>
<td> </td>
<td><a href="/?mid=trans" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image8','','menus/menu02_08b.gif',1)"><img src="menus/menu02_08.gif" name="Image8" width="200" height="23" border="0" id="Image8" /></a></td></tr>
<tr>
<td> </td>
<td><a href="/?mid=sports" onMouseOut="MM_swapImgRestore()" onMouseOver="MM_swapImage('Image9','','menus/menu02_09b.gif',1)"><img src="menus/menu02_09.gif" name="Image9" width="200" height="23" border="0" id="Image9" /></a></td></tr>
<tr>
<td width="15" valign="top"> </td>
<td width="200" height="2600" valign="top"><? include "adv.php"; ?></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td><img src="http://www.daegu-deaf.or.kr/ima/bottom_03.gif" /></td>
</tr>
</table>
<div id="gotop" style="position:absolute; left:0px; top:10px;">
<form>
<table border="0" cellpadding="0" cellspacing="0" valign="top" width=150>
<tr align=center>
<td colspan=3><strong>글자크기</strong></td>
</tr>
<tr align=center>
<td><input type="button" value="축소" onclick="javascript:zoomOut();"></td>
<td><input type="button" value="원위치" onclick="javascript:zoomReset();">
<td><input type="button" value="확대" onclick="javascript:zoomIn();"></td>
</tr>
<tr align=center>
<td colspan=3><strong><a href="#head" title="상단으로">TOP ▲</a>
</strong></td>
</tr>
</table>
</form>
</div>
<script type="text/javascript">initMoving(document.getElementById("gotop"), 500, 1, 1,1,1,1,1);</script>
</body>
</html>
이렇게 나옵니다..
빨간부분에 랜덤함수이에요..
왜 안먹힐까요?
오류 알려주세요!
나중에 이미지 추가나 제거를 대비해서 아래정도로 코드 구성해도 사용하면 어떨까 하는 생각입니다.
$aisimemo = array();
$aisimemo[] = 'ima/title_01.jpg';
$aisimemo[] = 'ima/title_02.jpg';
$aisimemo[] = 'ima/title_03.jpg';
$aisimemo[] = 'ima/title_04.jpg';
$aisicnt = rand(0, count($aisimemo)-1);
//이미지 출력
<? echo '<img src='.$aisimemo[$aisicnt].' />'; ?>