Nightwalker Posted August 29, 2006 Report Share Posted August 29, 2006 (edited) Всем привет.Есть таблица с отображением картинки и её имени.Но была проблема с именами картинок.Я исправил скрипт пхп на другой и теперь таблица не работает как нужно.Помогите найти где я допустил ошибку. Было так! <?phpfunction number_to_image($n){$arr=array('', 'картинка 1', 'картинка 2', 'картинка 3', 'картинка 4', 'картинка 5', 'картинка 6', 'картинка 7', 'картинка 8', 'картинка 9', 'картинка 10', 'картинка 11', 'картинка 12', 'картинка 13', 'картинка 14', 'картинка 15', 'картинка 16', 'картинка 17');$a=array("img/image".$n.".jpg",$arr[$n]);return $a;}function get_image(){$h = date("G");$d = date("w");if(($d>0) and ($d<6)){//понедельник-пятница if($h<7){ if($d==1){//понедельник return number_to_image(17); }else{//не понедельник return number_to_image(5); } }elseif(($h>=7) and ($h<11)){ return number_to_image(1); }elseif(($h>=11) and ($h<15)){ return number_to_image(2); }elseif(($h>=15) and ($h<19)){ return number_to_image(3); }elseif(($h>=19) and ($h<23)){ return number_to_image(4); }elseif($h>=23){ return number_to_image(5); }}elseif($d==6){//суббота if($h<9){ return number_to_image(5); }elseif(($h>=9) and ($h<12)){ return number_to_image(7); }elseif(($h>=12) and ($h<14)){ return number_to_image(8); }elseif(($h>=14) and ($h<18)){ return number_to_image(9); }elseif(($h>=18) and ($h<23)){ return number_to_image(10); }elseif($h>=23){ return number_to_image(11); }}elseif($d==0){//воскресенье if($h<9){ return number_to_image(11); }elseif(($h>=9) and ($h<12)){ return number_to_image(12); }elseif(($h>=12) and ($h<14)){ return number_to_image(13); }elseif(($h>=14) and ($h<16)){ return number_to_image(14); }elseif(($h>=16) and ($h<22)){ return number_to_image(15); }elseif($h>=22){ return number_to_image(16); }}}$arr = get_image();?><HTML><HEAD><TITLE>Now playing</TITLE><link href="../index.css" rel="stylesheet" type="text/css"></HEAD><BODY leftMargin=0 topMargin=0><table width="206" border="0" cellpadding="0" cellspacing="0"><tr><td height="36" width="206" style="background-image:url(../img/bgm1.gif); background-position:left top; background-repeat:no-repeat;"> <table width="206" height="36" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="66" style="padding-left:20px;"><img src="../img/icon_eteryje.gif" border="0"></td> <td width="140" class="title">On air</td> </tr> </table></td></tr><tr><td height="130" align="left" style="background-image:url(../img/bg3.gif); background-position:left top; background-repeat:repeat-y;" class="txtleft" valign="middle"> <img src="../img/bg10.gif" border="0"><a href="../indexmain.php@2_2F11_2F" target="_parent"><img src="../<?php print($arr[0]); ?>" border="0"> </a> <br><img src="../img/blank.gif" height="5"><br><div align="center"><?php print($arr[1]); ?></div></td></tr><tr><td height="3" style="background-image:url(../img/bg4.gif); background-position:left top; background-repeat:no-repeat;"><img src="../img/blank.gif" border="0"></td></tr></table></BODY></HTML> Я исправил на так <?php$H = (int)date("H");$D = (int)date("w");if (preg_match("/[1-5]/", $D)) {if ($H >= 7 && $H < 10) { $image = "image1.jpg"; $text = "Твой текст 1";} else if ($H >= 10 && $H < 13) { $image = "image2.jpg"; $text = "Твой текст 2";} else if ($H >= 13 && $H < 16) { $image = "image3.jpg"; $text = "Твой текст 3";} else if ($H >= 16 && $H < 19) { $image = "image4.jpg"; $text = "Твой текст 4";} else if ($H >= 19 && $H < 23) { $image = "image5.jpg"; $text = "Твой текст и т.д.";} else { $image = "image6.jpg"; $text = "Твой текст и т.д.";}} else {if ($D == "6") { if ($H >= 7 && $H < 9) { $image = "image6.jpg"; $text = "Твой текст и т.д."; } else if ($H >= 9 && $H < 12) { $image = "image1.jpg"; $text = "Твой текст и т.д."; } else if ($H >= 12 && $H < 14) { $image = "image2.jpg"; $text = "Твой текст и т.д."; } else if ($H >= 14 && $H < 18) { $image = "image3.jpg"; $text = "Твой текст и т.д."; } else if ($H >= 18 && $H < 23) { $image = "image4.jpg"; $text = "Твой текст и т.д."; } else { $image = "image5.jpg"; $text = "Твой текст и т.д."; }} else if ($D == "0") { if ($H >= 9 && $H < 12) { $image = "image1.jpg"; $text = "Твой текст и т.д."; } else if ($H >= 12 && $H < 14) { $image = "image2.jpg"; $text = "Твой текст и т.д."; } else if ($H >= 14 && $H < 16) { $image = "image3.jpg"; $text = "Твой текст и т.д."; } else if ($H >= 16 && $H < 22) { $image = "image4.jpg"; $text = "Твой текст и т.д."; } else if ($H >= 22) { $image = "image5.jpg"; $text = "Твой текст и т.д."; } else if ($H == 0) { $image = "image5.jpg"; $text = "Твой текст и т.д."; } else { $image = "image6.jpg"; $text = "Твой текст и т.д."; }}}?><img src="<?=$image?>"><?=$text?><HTML><HEAD><TITLE>Now playing</TITLE><link href="../index.css" rel="stylesheet" type="text/css"></HEAD><BODY leftMargin=0 topMargin=0><table width="206" border="0" cellpadding="0" cellspacing="0"><tr><td height="36" width="206" style="background-image:url(../img/bgm1.gif); background-position:left top; background-repeat:no-repeat;"> <table width="206" height="36" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="66" style="padding-left:20px;"><img src="../img/icon_eteryje.gif" border="0"></td> <td width="140" class="title">On air</td> </tr> </table></td></tr><tr><td height="130" align="left" style="background-image:url(../img/bg3.gif); background-position:left top; background-repeat:repeat-y;" class="txtleft" valign="middle"> <img src="../img/bg10.gif" border="0"><a href="../indexmain.php@2_2F11_2F" target="_parent"><img src="../<?php print($arr[0]); ?>" border="0"> </a> <br><img src="../img/blank.gif" height="5"><br><div align="center"><?php print($arr[1]); ?></div></td></tr><tr><td height="3" style="background-image:url(../img/bg4.gif); background-position:left top; background-repeat:no-repeat;"><img src="../img/blank.gif" border="0"></td></tr></table></BODY></HTML> И вот две разницы работы! До После Как видно текст отображается по разному.Скажите что я сделал не так?Нужно чтобы работало так как до моего исправления. Edited August 29, 2006 by Nightwalker Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now