
PHP菜鸟关于smarty第30讲中的缓存问题?
我看不懂下面代码?那位大虾能helpme......index.php<?phpinclude("smarty_inc.php");include("mysql_inc....
我看不懂下面代码?那位大虾能help me......
index.php
<?php
include("smarty_inc.php");
include("mysql_inc.php");
if ($GET[id]){
$sql="Select * from 'php100' where id=".$GET[id];
$query=$db->query($sql);
$row=$db->fetch_row($query);
$db->query('update php100 set hit=hit+1 where id='._GET[id]);
}
$smarty->assign('row',$row);
$smarty->display('index.htm');
//如果缓存开了,怎样不使用缓存呢?使用如下insert方式
function insert_hit(){
global $row;
return $row[2];
}
>
index.htm:
标题:{$row[1]}<br>
点击:{insert name="hit"}<br> 展开
index.php
<?php
include("smarty_inc.php");
include("mysql_inc.php");
if ($GET[id]){
$sql="Select * from 'php100' where id=".$GET[id];
$query=$db->query($sql);
$row=$db->fetch_row($query);
$db->query('update php100 set hit=hit+1 where id='._GET[id]);
}
$smarty->assign('row',$row);
$smarty->display('index.htm');
//如果缓存开了,怎样不使用缓存呢?使用如下insert方式
function insert_hit(){
global $row;
return $row[2];
}
>
index.htm:
标题:{$row[1]}<br>
点击:{insert name="hit"}<br> 展开
3个回答
展开全部
index.php
<?php
include("smarty_inc.php"); // 导入smarty配置文件
include("mysql_inc.php"); // 导入数据库配置文件
if ($GET[id]){ // 获取通过get方式传过来的 id 值
$sql="Select * from 'php100' where id=".$GET[id]; // 执行数据库操作搜索语句,执行条件 从‘php100’ 这张表查找id是否有与获取的id值相同的
$query=$db->query($sql); // 开始执行
$row=$db->fetch_row($query); // 获取结果集
$db->query('update php100 set hit=hit+1 where id='._GET[id]); // 更新操作 使查到的结果中的hit 加 1
}
$smarty->assign('row',$row); // 获取结果集 并存到变量 row 里面
$smarty->display('index.htm'); //显示
<?php
include("smarty_inc.php"); // 导入smarty配置文件
include("mysql_inc.php"); // 导入数据库配置文件
if ($GET[id]){ // 获取通过get方式传过来的 id 值
$sql="Select * from 'php100' where id=".$GET[id]; // 执行数据库操作搜索语句,执行条件 从‘php100’ 这张表查找id是否有与获取的id值相同的
$query=$db->query($sql); // 开始执行
$row=$db->fetch_row($query); // 获取结果集
$db->query('update php100 set hit=hit+1 where id='._GET[id]); // 更新操作 使查到的结果中的hit 加 1
}
$smarty->assign('row',$row); // 获取结果集 并存到变量 row 里面
$smarty->display('index.htm'); //显示
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询