查看: 6734|回复: 2
打印 上一主题 下一主题

PHP新闻信息自动更新代码实例

[复制链接]
跳转到指定楼层
1#
发表于 2007-9-30 14:44:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
台州网址导航
<?
require("include/dbfun.php");
require("include/common_var.php");
//require"../public/function.php";
function get_ms($s_time,$e_time)//$time是unix时间戳,得到秒数
{
if (!$s_time&&!$e_time) return false;
$s_time = strtotime($s_time);
$e_time = strtotime($e_time);
$s_diff =$e_time - $s_time;
return $s_diff;
}
///
               
include('Qindex/'.EIDADD.'.php');
$phpuptime=date("Y-m-d H:i:s");
$timeinfo_d=get_ms($htmluptime,$phpuptime);
if($timeinfo_d>5000 or !$htmluptime)
{
#####################################
$jobinfohtml.="var sHtml=\"\";";
$new_news_sql = "select id,title,datetime,bsortid,sortid from ".$article_table." where title like '%".CHINAADD."%' order by updatedt,datetime desc limit 0,8";                 
$db->execute($new_news_sql);
$num=$db->countnum();
while($artinfo_result=$db->reader())
{
        $nid = $artinfo_result['id'];
        $bs_id = $artinfo_result['bsortid'];
        $ss_id = $artinfo_result['sortid'];
        $title = cnsubstr($artinfo_result['title'],32);
        $jobinfohtml.="sHtml+=\"<tr>\";";
        $jobinfohtml.="sHtml+=\"<td width=\\\"10%\\\" height=\\\"20\\\"><div align=\\\"center\\\">?</div></td>\";";
        $jobinfohtml.="sHtml+=\"<td><a href=\\\"news\\/shownews.php?id=".$bs_id."&ssid=".$ss_id."&nid=".$nid."\\\" target=\\\"_blank\\\" class=\\\"web\\\" ><font color=\\\"#000000\\\">".$title."</font></a></td>\";";
        $jobinfohtml.="sHtml+=\"</tr>\";";
}
if($num!=8)
{
        $ii=8-$num;
        $new_news_sql = "select id,title,datetime,bsortid,sortid from ".$article_table." order by updatedt,datetime desc limit 0,"."$ii";                 
        $db->execute($new_news_sql);
        while($artinfo_result=$db->reader())
        {
                $nid = $artinfo_result['id'];
                $bs_id = $artinfo_result['bsortid'];
                $ss_id = $artinfo_result['sortid'];
                $title = cnsubstr($artinfo_result['title'],32);
                $jobinfohtml.="sHtml+=\"<tr>\";";
                $jobinfohtml.="sHtml+=\"<td width=\\\"10%\\\" height=\\\"20\\\"><div align=\\\"center\\\">?</div></td>\";";
                $jobinfohtml.="sHtml+=\"<td><a href=\\\"news\\/shownews.php?id=".$bs_id."&ssid=".$ss_id."&nid=".$nid."\\\" target=\\\"_blank\\\" class=\\\"web\\\" ><font color=\\\"#000000\\\">".$title."</font></a></td>\";";
                $jobinfohtml.="sHtml+=\"</tr>\";";
        }
}
        $jobinfohtml.="document.write (sHtml)";
#####################################


        $jobinfohtml.="<? \$htmluptime=\"$phpuptime\";?>";//将更新时间以php变量写入文件
               
        $file=fopen('Qindex/'.EIDADD.'.php','w'); //打开文件
        fwrite($file,$jobinfohtml); //写入信息
        fclose($file); //关闭文件
        if(!$htmluptime) echo"<meta http-equiv=\"refresh\" content=\"1\" /> 正在加载数据...";
}
?>

引用代码:<script language="javascript" src="news/n.php" type="text/javascript"></script>
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 转播转播 分享分享 分享淘帖
台州维博网络(www.tzweb.com)专门运用PHP+MYSQL/ASP.NET+MSSQL技术开发网站门户平台系统等。
2#
 楼主| 发表于 2007-9-30 14:46:09 | 只看该作者
台州网址导航
PHP新闻信息自动更新代码实例(二)

include('Qindex/'.EIDADD.'.php');
                $phpuptime=date("Y-m-d H:i:s");
                $timeinfo_d=get_ms($htmluptime,$phpuptime);
                if($timeinfo_d>1000 or !$htmluptime)
                {
               
                ########################################################################
                $jobinfohtml.="<table width=\"496\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
                $jobinfohtml.="          <tr>";
                $jobinfohtml.="            <td background=\"15hrimages/15hr_zpinfo_4.gif\"><img src=\"15hrimages/15hr_zpinfo_7.gif\" width=\"105\" height=\"29\"></td>";
                $jobinfohtml.="            <td background=\"15hrimages/15hr_zpinfo_4.gif\"><a href=\"Search_machine.php\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image70','','15hrimages/15hr_weburl_2_1.gif',1)\"><img src=\"15hrimages/15hr_zpinfo_2.gif\" name=\"Image70\" width=\"83\" height=\"29\" border=\"0\"></a></td>";
                $jobinfohtml.="            <td background=\"15hrimages/15hr_zpinfo_4.gif\"><a href=\"Seek_login.php\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('Image71','','15hrimages/15hr_weburl_3_1.gif',1)\"><img src=\"15hrimages/15hr_zpinfo_3.gif\" name=\"Image71\" width=\"82\" height=\"29\" border=\"0\"></a></td>";
                $jobinfohtml.="            <td background=\"15hrimages/15hr_zpinfo_4.gif\"><div align=\"right\"><a href=\"Info_invite.php\"><img src=\"15hrimages/15hr_zpinfo_5.gif\" width=\"144\" height=\"29\" border=\"0\"></a></div></td>";
                $jobinfohtml.="          </tr>";
                $jobinfohtml.="          <tr>";
                $jobinfohtml.="            <td colspan=\"4\" background=\"15hrimages/15hr_zpinfo_6.gif\"><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"5\">";
               
                $Register_date=date("Y-m-d");
                $strdo="select Bem_id,companyName from $job_bem where zpvip>$Register_date ".REGINFOSQL." order by adminuptime desc,Register_date desc limit 0,14";
                $result=mysql_query($strdo,$myconn);
                $jishu=1;
                while($rownew=mysql_fetch_row($result)) {
                list($Bem_id,$companyName)=$rownew;
                if ($jishu==1 || $jishu % 2 == 1) {
               
                $jobinfohtml.="                    <tr>";
                $jobinfohtml.="                      <td width=\"50%\" height=\"22\">?<a href=\"Info_invite_show.php?id="."$Bem_id"."\" target=\"_blank\" class=\"web\"><font color=\"#000000\">".cnsubstr($companyName,34)."</font></a></td>";
                }else{
                $jobinfohtml.="                      <td width=\"50%\" height=\"22\">?<a href=\"Info_invite_show.php?id="." $Bem_id"."\" target=\"_blank\" class=\"web\"><font color=\"#000000\">".cnsubstr($companyName,34)."</font></a></td>";
                }
                if ($jishu % 2==0) $jobinfohtml.="</tr>";
                $jishu++;
                }
                $jobinfohtml.="                </table></td>";
                $jobinfohtml.="          </tr>";
                $jobinfohtml.="          <tr>";
                $jobinfohtml.="            <td colspan=\"4\" bgcolor=\"#CCCCCC\"><img name=\"\" src=\"images/kb.gif\" width=\"1\" height=\"1\" alt=\"\" style=\"background-color: #CCCCCC\"></td>";
                $jobinfohtml.="          </tr>";
                $jobinfohtml.="        </table>";
                $jobinfohtml.="        <table width=\"100\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
                $jobinfohtml.="          <tr>";
                $jobinfohtml.="            <td> </td>";
                $jobinfohtml.="          </tr>";
                $jobinfohtml.="        </table>";
                $jobinfohtml.="        <table width=\"496\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";
                $jobinfohtml.="          <tr>";
                $jobinfohtml.="            <td background=\"15hrimages/15hr_zpinfo_4.gif\"><img src=\"15hrimages/15hr_zpinfo_1.gif\" width=\"105\" height=\"29\"></td>";
                $jobinfohtml.="            <td background=\"15hrimages/15hr_zpinfo_4.gif\"><a href=\"Search_machine.php\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('999','','15hrimages/15hr_weburl_2_1.gif',1)\"><img src=\"15hrimages/15hr_zpinfo_2.gif\" name=\"Image70\" width=\"83\" height=\"29\" border=\"0\"></a></td>";
                $jobinfohtml.="            <td background=\"15hrimages/15hr_zpinfo_4.gif\"><a href=\"Seek_login.php\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('999','','15hrimages/15hr_weburl_3_1.gif',1)\"><img src=\"15hrimages/15hr_zpinfo_3.gif\" name=\"Image71\" width=\"82\" height=\"29\" border=\"0\"></a></td>";
                $jobinfohtml.="            <td background=\"15hrimages/15hr_zpinfo_4.gif\"><div align=\"right\"><a href=\"Info_invite.php\"><img src=\"15hrimages/15hr_zpinfo_5.gif\" width=\"144\" height=\"29\" border=\"0\"></a></div></td>";
                $jobinfohtml.="          </tr>";
                $jobinfohtml.="          <tr>";
                $jobinfohtml.="            <td colspan=\"4\" background=\"15hrimages/15hr_zpinfo_6.gif\"><table width=\"100%\"  border=\"0\" cellspacing=\"0\" cellpadding=\"5\">";
               
                $Register_date=date("Y-m-d");
                $strdo="select t1.Bem_id,t1.companyName from $job_bem t1,$pass_time t2 where t1.Bem_id=t2.user_id ".REGINFOSQL." order by t2.Register_date desc limit 0,$new_d";
                $result=mysql_query($strdo,$myconn);
                $jishu=1;
                while($rownew=mysql_fetch_row($result)) {
                list($Bem_id,$companyName)=$rownew;
                if ($jishu==1 || $jishu % 2 == 1) {
               
                $jobinfohtml.="              <tr>";
                $jobinfohtml.="                <td width=\"50%\" height=\"22\">?<a href=\"Info_invite_show.php?id="."$Bem_id"."\" target=\"_blank\" class=\"web\"><font color=\"#000000\">".cnsubstr($companyName,34)."</font></a></td>";
                }else{
                $jobinfohtml.="                <td width=\"50%\" height=\"22\">?<a href=\"Info_invite_show.php?id="."$Bem_id"."\" target=\"_blank\" class=\"web\"><font color=\"#000000\">".cnsubstr($companyName,34)."</font></a></td>";
                }
                if ($jishu % 2==0) $jobinfohtml.="</tr>";
                $jishu++;
                }
                $jobinfohtml.="              </table></td>";
                $jobinfohtml.="          </tr>";
                $jobinfohtml.="          <tr>";
                $jobinfohtml.="            <td colspan=\"4\" bgcolor=\"#CCCCCC\"><img name=\"\" src=\"images/kb.gif\" width=\"1\" height=\"1\" alt=\"\" style=\"background-color: #CCCCCC\"></td>";
                $jobinfohtml.="          </tr>";
                $jobinfohtml.="        </table>";
                #################################################################
               
                $jobinfohtml.="<? \$htmluptime=\"$phpuptime\";?>";//将更新时间以php变量写入文件
               
                $file=fopen('Qindex/'.EIDADD.'.php','w'); //打开文件
                fwrite($file,$jobinfohtml); //写入信息
                fclose($file); //关闭文件
                        if(!$htmluptime) echo"<meta http-equiv=\"refresh\" content=\"1\" /> 正在加载数据...";
                }
台州维博网络(www.tzweb.com)专门运用PHP+MYSQL/ASP.NET+MSSQL技术开发网站门户平台系统等。
3#
 楼主| 发表于 2007-9-30 14:46:27 | 只看该作者
台州网址导航
PHP新闻信息自动更新生产的代码

var sHtml="";
sHtml+="<tr>";sHtml+="<td width=\"10%\" height=\"20\"><div align=\"center\">?</div></td>";
sHtml+="<td><a href=\"news\/shownews.php?id=1&ssid=2&nid=71\" target=\"_blank\" class=\"web\" ><font color=\"#000000\">青岛大批农民实现转移就业 推进城乡...</font></a></td>";
sHtml+="</tr>";sHtml+="<tr>";sHtml+="<td width=\"10%\" height=\"20\"><div align=\"center\">?</div></td>";
sHtml+="<td><a href=\"news\/shownews.php?id=1&ssid=7&nid=19\" target=\"_blank\" class=\"web\" ><font color=\"#000000\">中国人才评价突破</font></a></td>";
sHtml+="</tr>";
sHtml+="<tr>";
sHtml+="<td width=\"10%\" height=\"20\"><div align=\"center\">?</div></td>";
sHtml+="<td><a href=\"news\/shownews.php?id=8&ssid=12&nid=31\" target=\"_blank\" class=\"web\" ><font color=\"#000000\">电子杂志版简历登场“立体”展示自...</font></a></td>";
sHtml+="</tr>";
sHtml+="<tr>";
sHtml+="<td width=\"10%\" height=\"20\"><div align=\"center\">?</div></td>";
sHtml+="<td><a href=\"news\/shownews.php?id=1&ssid=4&nid=16\" target=\"_blank\" class=\"web\" ><font color=\"#000000\">管理故事:布里丹毛驴效应</font></a></td>";
sHtml+="</tr>";
sHtml+="<tr>";sHtml+="<td width=\"10%\" height=\"20\"><div align=\"center\">?</div></td>";
sHtml+="<td><a href=\"news\/shownews.php?id=1&ssid=6&nid=18\" target=\"_blank\" class=\"web\" ><font color=\"#000000\">协同软件发展方向:以人为本 注重过...</font></a></td>";
sHtml+="</tr>";sHtml+="<tr>";
sHtml+="<td width=\"10%\" height=\"20\"><div align=\"center\">?</div></td>";
sHtml+="<td><a href=\"news\/shownews.php?id=1&ssid=5&nid=17\" target=\"_blank\" class=\"web\" ><font color=\"#000000\">如何打造品牌员工?</font></a></td>";
sHtml+="</tr>";
sHtml+="<tr>";
sHtml+="<td width=\"10%\" height=\"20\"><div align=\"center\">?</div></td>";
sHtml+="<td><a href=\"news\/shownews.php?id=8&ssid=14&nid=32\" target=\"_blank\" class=\"web\" ><font color=\"#000000\">衡量职业状况满意程度标准:收入还...</font></a></td>";
sHtml+="</tr>";
sHtml+="<tr>";
sHtml+="<td width=\"10%\" height=\"20\"><div align=\"center\">?</div></td>";
sHtml+="<td><a href=\"news\/shownews.php?id=8&ssid=16&nid=34\" target=\"_blank\" class=\"web\" ><font color=\"#000000\">4类骗人职位被撵出招聘会</font></a></td>";
sHtml+="</tr>";
document.write (sHtml)
<? $htmluptime="2006-09-04 00:56:19";?>
台州维博网络(www.tzweb.com)专门运用PHP+MYSQL/ASP.NET+MSSQL技术开发网站门户平台系统等。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

网站推广
关于我们
  • 台州朗动科技(Tzweb.com)拥有多年开发网站平台系统门户手机客户端等业务的成功经验。主要从事:政企网站,系统平台,微信公众号,各类小程序,手机APP客户端,浙里办微应用,浙政钉微应用、主机域名、虚拟空间、后期维护等服务,满足不同企业公司的需求,是台州地区领先的网络技术服务商!

Hi,扫描关注我

Copyright © 2005-2026 站长论坛 All rights reserved

Powered by 站长论坛 with TZWEB Update Techonolgy Support

快速回复 返回顶部 返回列表