各位帮小弟解决一下生成静态页面后连接的问题,我今天搞了半天都没有做出来,急呀!! 生成0000001000006.htm文件就可以了啊。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 可是用什么来取得 <option></option>之间的内容呢?应该不能这样。如果用DHTML应该就可以吧。但是写法都不一样啦。 你的模板是怎样写的?你可能是这样写的<td><a href='{url}?id={id}&sheng={text}'>{text}</a></td>处理时$ar = array(url => "next.php", id => $id, text => $text);$tpl->setvar($ar);如果你写作<td><a href='{url}'>{text}</a></td>处理时动态页面$ar = array(url => "next.php?id=$id&sheng=$text", text => $text);$tpl->setvar($ar);静态页面$ar = array(url => "$id.htm", text => $text);$tpl->setvar($ar);这样就可以了 <?phpinclude_once("../config/config.php");include_once("../config/template.inc");include_once("../config/var.php");$temp = new template();$temp -> set_file("file","index.htm");$sql = "select * from zone where len(zone_code)>7 and len(zone_code)<=12";$result = new DB_Sql();$result -> connect();$result -> query($sql);$num = $result -> nf();for($i=0;$i<$num;$i++){ $result -> next_record(); if($i%3==0) { $area.="<tr>"; } $area.="<td width='6%'><img src='images/ic03.gif' width='30' height='29'></td> <td width='27%'><a href='next.php?id=".$result -> f("zone_code")."&sheng=".$result -> f("zone_name")."'>".$result -> f("zone_name")."</a></td>"; if(($i+1)%3==0) { $area.="</tr>"; }}$temp -> set_var("area",$area);$temp -> parse("out","file");$temp->savetofile("index.html", "out");$temp->renew(); header("Location:index.html");?>这是我的摸板 这是生成模板的函数,唠叨老大帮帮忙 /**************************************** * 函数名:savetofile($dir, $varName) * * 参 数:$dir:保存到的目录 * $varName:保存的文件名 * 作 者:ccterran */ function savetofile($dir, $varname) { $data = $this->finish($this->get_var($varname)); $fp = fopen($dir, "w+"); fwrite($fp, $data); } /************************************* * 函数名:renew() * * 作 者:ccterran */ function renew() { $this->varkeys = array(); $this->varvals = array(); $this->file = array(); } 你那是在使用模板吗?不仅<td><a>标记甚至<tr>标记都出现在程序里,那还不如不用模板呢!按你的程序就直接修改循环中对$area赋值的语句吧 <?phpinclude_once("../config/config.php");include_once("../config/template.inc");include_once("../config/var.php");$temp = new template();$temp -> set_file("file","index.htm");$sql = "select * from zone where len(zone_code)>7 and len(zone_code)<=12";$result = new DB_Sql();$result -> connect();$result -> query($sql);$num = $result -> nf();for($i=0;$i<$num;$i++){ $result -> next_record(); //这里没有必要这么写,在模板添加一个变量,当$i==3时用"<br/>"替换这个变量 if($i%3==0) { $area.="<tr>"; } $area.="<td width='6%'><img src='images/ic03.gif' width='30' height='29'></td> <td width='27%'> //这里改了 <a href='".$result -> f("zone_code")."htm'>".$result -> f("zone_name")."</a></td>"; if(($i+1)%3==0) { $area.="</tr>"; }}$temp -> set_var("area",$area);$temp -> parse("out","file");$temp->savetofile("index.html", "out");$temp->renew(); header("Location:index.html");?> 当$i==3时用"<br/>"替换这个变量写错了当$i==3时用"<tr/><tr>"替换这个变量 请教PHP全局变量问题? 请教php调用c#的webservice的方法 PHP 可以与Microsoft SQL Server 一起用吗? 在php分页时 POST 传递的值 点下一页是没有了,该怎么办 日期显示问题 php+IIS+mysql配置中的问题,请大家帮忙! sql语句查不到记录 这个问题不知道如何描述,简体转繁体后居然语法出错! 请问怎样用PHP操作APACHE的虚似主机 有人想收个徒弟吗??? php页面回滚求教!! 网页做出那种像软件界面的线条什么的是怎么弄的啊
之间的内容呢?
应该不能这样。
如果用DHTML
应该就可以吧。
但是写法都不一样啦。
<td><a href='{url}?id={id}&sheng={text}'>{text}</a></td>
处理时
$ar = array(url => "next.php", id => $id, text => $text);
$tpl->setvar($ar);如果你写作
<td><a href='{url}'>{text}</a></td>
处理时
动态页面
$ar = array(url => "next.php?id=$id&sheng=$text", text => $text);
$tpl->setvar($ar);
静态页面
$ar = array(url => "$id.htm", text => $text);
$tpl->setvar($ar);这样就可以了
include_once("../config/config.php");
include_once("../config/template.inc");
include_once("../config/var.php");
$temp = new template();
$temp -> set_file("file","index.htm");
$sql = "select * from zone where len(zone_code)>7 and len(zone_code)<=12";
$result = new DB_Sql();
$result -> connect();
$result -> query($sql);
$num = $result -> nf();
for($i=0;$i<$num;$i++)
{
$result -> next_record();
if($i%3==0)
{
$area.="<tr>";
}
$area.="<td width='6%'><img src='images/ic03.gif' width='30' height='29'></td>
<td width='27%'><a href='next.php?id=".$result -> f("zone_code")."&sheng=".$result -> f("zone_name")."'>".$result -> f("zone_name")."</a></td>";
if(($i+1)%3==0)
{
$area.="</tr>";
}
}
$temp -> set_var("area",$area);
$temp -> parse("out","file");
$temp->savetofile("index.html", "out");
$temp->renew();
header("Location:index.html");
?>
这是我的摸板
/****************************************
* 函数名:savetofile($dir, $varName)
*
* 参 数:$dir:保存到的目录
* $varName:保存的文件名
* 作 者:ccterran
*/
function savetofile($dir, $varname)
{
$data = $this->finish($this->get_var($varname));
$fp = fopen($dir, "w+");
fwrite($fp, $data);
} /*************************************
* 函数名:renew()
*
* 作 者:ccterran
*/
function renew()
{
$this->varkeys = array();
$this->varvals = array();
$this->file = array();
}
include_once("../config/config.php");
include_once("../config/template.inc");
include_once("../config/var.php");
$temp = new template();
$temp -> set_file("file","index.htm");
$sql = "select * from zone where len(zone_code)>7 and len(zone_code)<=12";
$result = new DB_Sql();
$result -> connect();
$result -> query($sql);
$num = $result -> nf();
for($i=0;$i<$num;$i++)
{
$result -> next_record();
//这里没有必要这么写,在模板添加一个变量,当$i==3时用"<br/>"替换这个变量
if($i%3==0)
{
$area.="<tr>";
}
$area.="<td width='6%'><img src='images/ic03.gif' width='30' height='29'></td>
<td width='27%'>
//这里改了
<a href='".$result -> f("zone_code")."htm'>".$result -> f("zone_name")."</a></td>";
if(($i+1)%3==0)
{
$area.="</tr>";
}
}
$temp -> set_var("area",$area);
$temp -> parse("out","file");
$temp->savetofile("index.html", "out");
$temp->renew();
header("Location:index.html");
?>
写错了
当$i==3时用"<tr/><tr>"替换这个变量