页面是生成成功了的.但每页内容都一样.为什么呢?
全部代码如下
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<?
$cid=$_REQUEST['cid'];
require_once('inc/connection.php');
$templethtml ="news_class.html";
//模版文件
$templets="../../templets/".$templethtml;
//模版路径
if($readfile = fopen($templets,"rb")){
while(!feof($readfile)){
$htmlcontent = fread($readfile,1000000);
$filecontent = $htmlcontent;
}fclose ($readfile);
}else{
echo "<script>alert('模版文件读取失败,可能模版文件过大!');location.href='index.php';</script>";
}$config_info_sql="SELECT *
FROM `sys_company_config`
WHERE `SCCO_ID` = '1'";
$config_info_rs=mysql_query($config_info_sql);
$config_info_row=mysql_fetch_row($config_info_rs);
//站点设置信息表
$webgjz=$config_info_row[2];
$webname=$config_info_row[1];
$tel=$config_info_row[4];
$ad=$config_info_row[6];
$meil=$config_info_row[7];
$copy=$config_info_row[11];
$icp=$config_info_row[8];
$add=$config_info_row[9];
$sm=$config_info_row[10];$class_sql="SELECT * FROM `td_news_class` WHERE `TNCL_ID` = '$cid'";
$class_rs=mysql_query($class_sql);
$class_row=mysql_fetch_row($class_rs);
//新闻类别表查询
$content_classname=$class_row[2];//新闻类别名称
$content_classid=$class_row[0];//新闻类别ID$news_detailed_sj_sql="SELECT * FROM `td_news_info` WHERE `TNCL_ID`='3' AND `TNIN_CHECK_FLAG` ='1' AND `TNIN_SHOW_FLAG` ='0' ORDER BY `TNIN_DATETIME` DESC ";
$news_detailed_sj_rs=mysql_query($news_detailed_sj_sql);
while ($news_detailed_sj_row=mysql_fetch_row($news_detailed_sj_rs)){
$news_detailed_sj_row_zifu=cut($news_detailed_sj_row[3], 27);
$news_detailed_sj_row_time=substr($news_detailed_sj_row[6],5,2)."/".substr($news_detailed_sj_row[6],8,2);//日期
$news_time_file=substr($news_detailed_sj_row[6],2,2).substr($news_detailed_sj_row[6],5,2);//目录
$sjlist .=" ·<a href='/html/$news_detailed_sj_row[1]/$news_time_file/$news_detailed_sj_row[0].html'>$news_detailed_sj_row_zifu</a> $news_detailed_sj_row_time<br/>";
$d++;if($d>9)break;}
//查询优惠活动新闻
$news_detailed_tja_sql="SELECT * FROM `td_news_info` WHERE `TNCL_ID`='$cid' AND `TNIN_pic_FLAG` ='1' AND `TNIN_CHECK_FLAG` ='1' AND `TNIN_SHOW_FLAG` ='0' ORDER BY `TNIN_HIT` ASC ";
$news_detailed_tja_rs=mysql_query($news_detailed_tja_sql);
while ($news_detailed_tja_row=mysql_fetch_row($news_detailed_tja_rs)){
$news_detailed_tja_row_zifu=cut($news_detailed_tja_row[3], 20);
$news_detailed_tja_time_file=substr($news_detailed_tja_row[6],2,2).substr($news_detailed_tja_row[6],5,2);//目录
$tjlist .="<div class='m_top2'><div class='pic_link padt3'><A href='/html/$news_detailed_tja_row[1]/$news_detailed_tja_time_file/$news_detailed_tja_row[0].html'><img src='$news_detailed_tja_row[4]' width='140' height='100' /></A></div><div class='a_link m_top2 text_center'><a href='/html/$news_detailed_tja_row[1]/$news_detailed_tja_time_file/$news_detailed_tja_row[0].html'>$news_detailed_tja_row_zifu</div> </div></a><br/>";
$e++;if($e>1)break;}
//推荐图文新闻$news_detailed_tj_sql="SELECT * FROM `td_news_info` WHERE `TNCL_ID`='$cid' AND `TNIN_RECO_FLAG` ='1' AND `TNIN_CHECK_FLAG` ='1' AND `TNIN_SHOW_FLAG` ='0' ORDER BY `TNIN_HIT` ASC ";
$news_detailed_tj_rs=mysql_query($news_detailed_tj_sql);
while ($news_detailed_tj_row=mysql_fetch_row($news_detailed_tj_rs)){
$news_detailed_tj_row_zifu=cut($news_detailed_tj_row[3], 20);
$news_detailed_tj_time_file=substr($news_detailed_tj_row[6],2,2).substr($news_detailed_tj_row[6],5,2);//目录
$tjalist .="<a href='/html/$news_detailed_tj_row[1]/$news_detailed_tj_time_file/$news_detailed_tj_row[0].html'>· $news_detailed_tj_row_zifu</a><br/>";
$e++;if($e>7)break;}
//推荐新闻$news_detailed_hot_sql="SELECT * FROM `td_news_info` WHERE `TNCL_ID`='$cid' AND `TNIN_CHECK_FLAG` ='1' AND `TNIN_SHOW_FLAG` ='0' ORDER BY `TNIN_HIT` ASC ";
$news_detailed_hot_rs=mysql_query($news_detailed_hot_sql);
while ($news_detailed_hot_row=mysql_fetch_row($news_detailed_hot_rs)){
$news_detailed_hot_row_zifu=cut($news_detailed_hot_row[3], 20);
$news_detailed_hot_time_file=substr($news_detailed_hot_row[6],2,2).substr($news_detailed_hot_row[6],5,2);//目录
$hotlist .="<a href='/html/$news_detailed_hot_row[1]/$news_detailed_hot_time_file/$news_detailed_hot_row[0].html'>·
$news_detailed_hot_row_zifu</a><br/>";
$e++;if($e>10)break;}
//热点新闻
if($cid!=" "){
$htmlurl="../../html/";//定义页面保存路径
$htmlcfile=$htmlurl.$cid."/";//定义新闻类别目录
if(!file_exists($htmlcfile)){
mkdir($htmlcfile,0777);
}
$pagesize="10";
$news_sql="SELECT * FROM `td_news_info` WHERE `TNCL_ID` = '$cid' AND `TNIN_CHECK_FLAG` ='1' AND `TNIN_SHOW_FLAG` ='0' ORDER BY `TNIN_DATETIME` DESC";
$news_rs=mysql_query($news_sql);
$news_num=mysql_num_rows($news_rs);
//所属类别新闻信息表查询
if($news_num<$pagesize) $pages = 1;
if($news_num%$pagesize){
$pages = intval($news_num/$pagesize)+1;
}else{
$pages = intval($news_num/$pagesize);
}
全部代码如下
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++<?
$cid=$_REQUEST['cid'];
require_once('inc/connection.php');
$templethtml ="news_class.html";
//模版文件
$templets="../../templets/".$templethtml;
//模版路径
if($readfile = fopen($templets,"rb")){
while(!feof($readfile)){
$htmlcontent = fread($readfile,1000000);
$filecontent = $htmlcontent;
}fclose ($readfile);
}else{
echo "<script>alert('模版文件读取失败,可能模版文件过大!');location.href='index.php';</script>";
}$config_info_sql="SELECT *
FROM `sys_company_config`
WHERE `SCCO_ID` = '1'";
$config_info_rs=mysql_query($config_info_sql);
$config_info_row=mysql_fetch_row($config_info_rs);
//站点设置信息表
$webgjz=$config_info_row[2];
$webname=$config_info_row[1];
$tel=$config_info_row[4];
$ad=$config_info_row[6];
$meil=$config_info_row[7];
$copy=$config_info_row[11];
$icp=$config_info_row[8];
$add=$config_info_row[9];
$sm=$config_info_row[10];$class_sql="SELECT * FROM `td_news_class` WHERE `TNCL_ID` = '$cid'";
$class_rs=mysql_query($class_sql);
$class_row=mysql_fetch_row($class_rs);
//新闻类别表查询
$content_classname=$class_row[2];//新闻类别名称
$content_classid=$class_row[0];//新闻类别ID$news_detailed_sj_sql="SELECT * FROM `td_news_info` WHERE `TNCL_ID`='3' AND `TNIN_CHECK_FLAG` ='1' AND `TNIN_SHOW_FLAG` ='0' ORDER BY `TNIN_DATETIME` DESC ";
$news_detailed_sj_rs=mysql_query($news_detailed_sj_sql);
while ($news_detailed_sj_row=mysql_fetch_row($news_detailed_sj_rs)){
$news_detailed_sj_row_zifu=cut($news_detailed_sj_row[3], 27);
$news_detailed_sj_row_time=substr($news_detailed_sj_row[6],5,2)."/".substr($news_detailed_sj_row[6],8,2);//日期
$news_time_file=substr($news_detailed_sj_row[6],2,2).substr($news_detailed_sj_row[6],5,2);//目录
$sjlist .=" ·<a href='/html/$news_detailed_sj_row[1]/$news_time_file/$news_detailed_sj_row[0].html'>$news_detailed_sj_row_zifu</a> $news_detailed_sj_row_time<br/>";
$d++;if($d>9)break;}
//查询优惠活动新闻
$news_detailed_tja_sql="SELECT * FROM `td_news_info` WHERE `TNCL_ID`='$cid' AND `TNIN_pic_FLAG` ='1' AND `TNIN_CHECK_FLAG` ='1' AND `TNIN_SHOW_FLAG` ='0' ORDER BY `TNIN_HIT` ASC ";
$news_detailed_tja_rs=mysql_query($news_detailed_tja_sql);
while ($news_detailed_tja_row=mysql_fetch_row($news_detailed_tja_rs)){
$news_detailed_tja_row_zifu=cut($news_detailed_tja_row[3], 20);
$news_detailed_tja_time_file=substr($news_detailed_tja_row[6],2,2).substr($news_detailed_tja_row[6],5,2);//目录
$tjlist .="<div class='m_top2'><div class='pic_link padt3'><A href='/html/$news_detailed_tja_row[1]/$news_detailed_tja_time_file/$news_detailed_tja_row[0].html'><img src='$news_detailed_tja_row[4]' width='140' height='100' /></A></div><div class='a_link m_top2 text_center'><a href='/html/$news_detailed_tja_row[1]/$news_detailed_tja_time_file/$news_detailed_tja_row[0].html'>$news_detailed_tja_row_zifu</div> </div></a><br/>";
$e++;if($e>1)break;}
//推荐图文新闻$news_detailed_tj_sql="SELECT * FROM `td_news_info` WHERE `TNCL_ID`='$cid' AND `TNIN_RECO_FLAG` ='1' AND `TNIN_CHECK_FLAG` ='1' AND `TNIN_SHOW_FLAG` ='0' ORDER BY `TNIN_HIT` ASC ";
$news_detailed_tj_rs=mysql_query($news_detailed_tj_sql);
while ($news_detailed_tj_row=mysql_fetch_row($news_detailed_tj_rs)){
$news_detailed_tj_row_zifu=cut($news_detailed_tj_row[3], 20);
$news_detailed_tj_time_file=substr($news_detailed_tj_row[6],2,2).substr($news_detailed_tj_row[6],5,2);//目录
$tjalist .="<a href='/html/$news_detailed_tj_row[1]/$news_detailed_tj_time_file/$news_detailed_tj_row[0].html'>· $news_detailed_tj_row_zifu</a><br/>";
$e++;if($e>7)break;}
//推荐新闻$news_detailed_hot_sql="SELECT * FROM `td_news_info` WHERE `TNCL_ID`='$cid' AND `TNIN_CHECK_FLAG` ='1' AND `TNIN_SHOW_FLAG` ='0' ORDER BY `TNIN_HIT` ASC ";
$news_detailed_hot_rs=mysql_query($news_detailed_hot_sql);
while ($news_detailed_hot_row=mysql_fetch_row($news_detailed_hot_rs)){
$news_detailed_hot_row_zifu=cut($news_detailed_hot_row[3], 20);
$news_detailed_hot_time_file=substr($news_detailed_hot_row[6],2,2).substr($news_detailed_hot_row[6],5,2);//目录
$hotlist .="<a href='/html/$news_detailed_hot_row[1]/$news_detailed_hot_time_file/$news_detailed_hot_row[0].html'>·
$news_detailed_hot_row_zifu</a><br/>";
$e++;if($e>10)break;}
//热点新闻
if($cid!=" "){
$htmlurl="../../html/";//定义页面保存路径
$htmlcfile=$htmlurl.$cid."/";//定义新闻类别目录
if(!file_exists($htmlcfile)){
mkdir($htmlcfile,0777);
}
$pagesize="10";
$news_sql="SELECT * FROM `td_news_info` WHERE `TNCL_ID` = '$cid' AND `TNIN_CHECK_FLAG` ='1' AND `TNIN_SHOW_FLAG` ='0' ORDER BY `TNIN_DATETIME` DESC";
$news_rs=mysql_query($news_sql);
$news_num=mysql_num_rows($news_rs);
//所属类别新闻信息表查询
if($news_num<$pagesize) $pages = 1;
if($news_num%$pagesize){
$pages = intval($news_num/$pagesize)+1;
}else{
$pages = intval($news_num/$pagesize);
}
解决方案 »
- 在中图片植入代码
- preg_replace 替换的问题
- Catchable fatal error: Object of class dUser could not be converted to string in on line 16
- 请教 这个正则表达式怎么写?
- openssl.dll配置问题
- 帮朋友找个兼职PHP程序员
- 想不起来该怎么办了!!!!!!!!!!急啊!!
- 我在该站传递参数后面加了单引号结果显示的仍然是对应页面,这种效果是怎么实现的?
- 关于session的错误~~~~急!!!!!!!
- 请教mysql存储过程执行成功,php却取不到值
- 如何验证日期和日期是否正确?
- 分享----避免无端的 php 站的被人入侵。。。。。。
$page_turn="";
if($i==0){
$indexpath="index.html";
$page_turn.="第一页 | 上一页";
}else{
$indexpath="index_".$i.".html";
$page_turn.="<a href='index.html'>第一页</a> | <a href='index_".($i-1).".html'>上一页</a>";
}
if($i==$pages){
$page_turn.=' | 下一页 | 最后一页';
}else{
$page_turn.=" | <a href='index_".($i+1).".html'>下一页</a> | <a href='index_".($pages-1).".html'>最后一页</a>";
}
$apage=$i*$pagesize;
$newsclass_sql="SELECT * FROM `td_news_info` WHERE `TNCL_ID` = '$cid' AND `TNIN_CHECK_FLAG` ='1' AND `TNIN_SHOW_FLAG` ='0' ORDER BY `TNIN_DATETIME` DESC limit $apage,$pagesize";
$newsclass_rs=mysql_query($newsclass_sql);
$newsclass_row=mysql_num_rows($newsclass_rs);
$j=1;
$newsclist="";
while($j<=$newsclass_row){
$newsclass_row_doc=mysql_fetch_array($newsclass_rs);
$news_detailed_row_zifu=cut($newsclass_row_doc[3], 80);//标题
$news_detailed_row_time=substr($newsclass_row_doc[6],5,2)."/".substr($newsclass_row_doc[6],8,2);//日期
$news_time_file=substr($newsclass_row_doc[6],2,2).substr($newsclass_row_doc[6],5,2);//目录
$newsclist .=" <a href='/html/$newsclass_row_doc[1]/$news_time_file/$newsclass_row_doc[0].html'>·$news_detailed_row_zifu</a> $news_detailed_row_time<br/>";
$j+=1;
}
$filename=$htmlcfile.$indexpath;
if (is_file ($filename)){
@unlink ($filename); //若文件已存在,则删除
}
if($fp = fopen($filename, "x")){//新建文件,开始写入下面的内容
$filecontent = str_replace("{nid}",$nid, $filecontent);
$filecontent = str_replace("{cid}",$cid, $filecontent);
$filecontent = str_replace("{webgjz}",$webgjz, $filecontent);
$filecontent = str_replace("{webname}",$webname, $filecontent);
$filecontent = str_replace("{tel}",$tel, $filecontent);
$filecontent = str_replace("{ad}",$ad, $filecontent);
$filecontent = str_replace("{meil}",$meil, $filecontent);
$filecontent = str_replace("{copy}",$copy, $filecontent);
$filecontent = str_replace("{icp}",$icp, $filecontent);
$filecontent = str_replace("{add}",$add, $filecontent);
$filecontent = str_replace("{sm}",$sm, $filecontent);
$filecontent = str_replace("{page_turn}",$page_turn, $filecontent);
$filecontent = str_replace("{content}",$newsclist, $filecontent);
$filecontent = str_replace("{classname}",$content_classname, $filecontent);
$filecontent = str_replace("{classid}",$content_classid, $filecontent);
$filecontent = str_replace("{tjlist}",$tjlist, $filecontent);
$filecontent = str_replace("{tjalist}",$tjalist, $filecontent);
$filecontent = str_replace("{hotlist}",$hotlist, $filecontent);
$filecontent = str_replace("{sjlist}",$sjlist,$filecontent);
if (!is_writable ($filename)){
die ("文件:".$filename."不可写,请检查其属性后重试!");
}
if(!fwrite($fp, $filecontent)){
fclose($fp);//关闭指针
unlink($filename);//关闭文件
echo "<script>alert('生成失败');location.href='index.php?action=list';</script>";
exit;
}
}else{
unlink($filename);//关闭文件
echo "<script>alert('生成失败!');location.href='index.php?action=list';</script>";
}
}
echo "<script>alert('生成成功!');location.href='index.php?action=list';</script>";
}?>++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++