首頁  >  文章  >  後端開發  >  php写每周数据问题代码

php写每周数据问题代码

WBOY
WBOY原創
2016-06-23 14:16:001016瀏覽

php 每周数据



自已写了一段PHP,发现只能读取当今天的数据,前几天的没显示出来,高手看看应怎改。

<?php@header("content-Type: text/html; charset=utf-8");require_once 'inc/site_config.php';require_once 'inc/db_connections.php';require_once 'inc/function.php';mysql_query('set character set "utf8"');?><!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></head><script type="text/javascript" src="http://www.hkjinku.com/statics/js/jquery.js"></script><!--导航JS--><script type="text/javascript" src="http://www.hkjinku.com/statics/js/function.js"></script><!--导航JS--><script type="text/javascript" src="http://www.hkjinku.com/statics/js/home.js"></script><!--选项卡--><style type="text/css"><!--@font-face { font-family:"微软雅黑"; src:url("微软雅黑.ttf");} *{margin:0px auto;padding:0px; }body {    color: #666666;    font-size: 12px;}a:link,a:visited,a:hover,a:active{color: #666666;text-decoration: none; font-size:12px;}/*全球经济数据*/#qqjjsj{float:left; overflow:hidden; width:580px; margin-bottom:10px;}#qqjjsj_title{	height:30px;	background:url(http://www.hkjinku.com/statics/2013/element.gif) 0 -109px repeat-x;	margin:0 6px;}#qqjjsj_title li{	float:left;	width:110px;	height:30px;	line-height: 34px;	font-weight:bold;	font-size:14px;	display:inline;	cursor:pointer;	text-align:center;}#qqjjsj_title li.active{	background-image:url(http://www.hkjinku.com/statics/2013/element.gif);	background-position:-2px -60px;	background-repeat:no-repeat;	color:#FFF;}#qqjjsj_title li.unactive{	background-image:url(http://www.hkjinku.com/statics/2013/element.gif);	background-position:0 -109px;	background-repeat:repeat-x;	color:#CCC;}#qqjjsj_content{ float:left; width:570px; border:#381610 5px solid; overflow:hidden;}.tab-hd{ height:30px;}.tab-bd{ height:150px; overflow:hidden;}.tab-bd .scrollFlow{ height:300px; overflow:hidden;}.tab-bd .item{ height:150px; display:block; }.tab-dl dl{ width:100%; height:30px; cursor:pointer;}.tab-dl dl.wi-hd dt,.tab-dl dl.wi-hd dd{ background:url(http://www.hkjinku.com/statics/2013/element.gif) 0 -155px repeat-x; color:#381610;}.tab-dl dl.wi-item:hover dt,.tab-dl dl.wi-item:hover dd{ background:#e5bd78; color:#FFF;}.tab-dl dt,.tab-dl dd{ height:24px; line-height:24px; text-align:center; float:left; display:inline;border:1px solid #CCC;box-shadow:1px 1px 1px #c2c2c2; margin:2px; color:#888888; font-weight:700; font-size:14px; overflow:hidden; }.tab-dl dt{ width:258px;}.tab-dl dd.i1{ width:70px;}.tab-dl dd.i2{ width:70px;}.tab-dl dd.i3{ width:60px;}.tab-dl dd.i4{ width:80px;}.qqjjsj_url{ margin:7px 10px;}--></style><body><!--全球经济数据-->      <div id="qqjjsj">              <div id="qqjjsj_title">              	<ul>                <?php               $j = 0;                for( $i = 0; $i <7; $i++ ){ //循环输出7天日期                	if( (date('N',strtotime('-'.$i.' day'))) < 6 ){  //排除星期六天                    echo '<li class="'.(( $j == 0 )?"active":"unactive").'" id="qqjjsj'.$j.'" onmouseover="javascript:Show(\''.$j.'\',\'5\',\'qqjjsj\',\'active\',\'unactive\')">'.(date('n月d日',strtotime('-'.$i.' day'))).'</li>';                    $j++;                	}                }				?>                				</ul>              </div>               <div id="qqjjsj_content">              	            <?php            $j = 0;            for( $i = 0; $i <7; $i++ ){ //循环输出7天内数据            if( (date('N',strtotime('-'.$i.' day'))) < 6 ){  //排除星期六天                $cur_time = mktime(0, 0, 0, date("m")  , (date("d")-$i), date("Y")); //当天时间戳                $next_time = mktime(0, 0, 0, date("m")  , (date("d")+1-$i), date("Y")); //第二天时间戳                $where = "`AccTime` >= '$cur_time' AND `AccTime` < '$next_time'";				echo '<div style="display: '.(( $j == 0 )?"block":"none").';" id="qqjjsj'.$j.'_nr">';                ?>                <div class="tab-dl tab-hd">                    <dl class="wi-hd">                    	<dt>事件</dt>                    	<dd class="i1">前值</dd>                        <dd class="i2">预期值</dd>                        <dd class="i3">时间</dd>                        <dd class="i4">日期</dd>                    </dl>                </div>                <div class="tab-dl tab-bd scrollBox<?php echo $j?>">                	<div class="scrollFlow">    				<div id="scroll_a<?php echo $j?>" class="item">                <?php				$s_arr=array();				$i=0;				$service_rs=mysql_query("select * from info where CateId='8' and $where order by InfoId desc limit 10");				while($service_row=mysql_fetch_assoc($service_rs))				{					$s_arr[$i++]=$service_row;				}								for($i=0;$i<10;$i++)				{			?>                    <dl class="wi-item">                    	<dt><a href="info_detail.php?InfoId=<?=$s_arr[$i]['InfoId']?>" target="_blank"><?=$s_arr[$i]['Title']?></a></dt>                    	<dd class="i1"><?=$s_arr[$i]['qz']?></dd>                        <dd class="i2"><?=$s_arr[$i]['yqz']?></dd>                        <dd class="i3"><?=$s_arr[$i]['time']?></dd>                        <dd class="i4"><?=$s_arr[$i]['AccTime']?></dd>                    </dl>                  <?php } ?>                    </div>                    <div id="scroll_b<?php echo $j?>" class="item"></div>                    </div>   <script type="text/javascript">scrolltop("#scroll_a<?php echo $j?>","#scroll_b<?php echo $j?>",".scrollBox<?php echo $j?>");</script>                                                    </div>            <?php            	echo '</div>';                $j++;            }            }             ?>              	<div class="qqjjsj_url"><a href="news.php?CateId=8" target="_blank"><img  src="http://www.hkjinku.com/statics/2013/qqjjsj.jpg" / alt="php写每周数据问题代码" ></a></div>              </div>                    </div></body></html>

回复讨论(解决方案)

第101行 的 for( $i = 0; $i  内嵌第130行的 for($i=0;$i
你觉得合理吗?

原来是那里问题,把130行的改成I1解决了。。

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn