站长论坛
标题:
PHP新闻信息自动更新代码实例
[打印本页]
作者:
tzlink
时间:
2007-9-30 14:44
标题:
PHP新闻信息自动更新代码实例
<?
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>
作者:
tzlink
时间:
2007-9-30 14:46
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\" /> 正在加载数据...";
}
作者:
tzlink
时间:
2007-9-30 14:46
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";?>
欢迎光临 站长论坛 (http://www.tzlink.com/bbs/)
Powered by Discuz! X3.2