11-16明天要回家了,今天上午的代码子发出来吧!
2012-11-16 12:10
134 查看
stu_info.tpl
<{config_load file="test.conf"}>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>学生基本信息</title>
</head>
<body>
<center>
<h3>学生基本信息</h3>
<table bgcolor='<{#table_bgcolor#}>' border='1'>
<tr bgcolor='<{#head_color#}>'>
<th>学号</th><th>姓名</th><th>生日</th><th>成绩</th><th>详细信息</th>
</tr>
<{section name='stu' loop=$array}>
<{if $smarty.section.stu.index is odd}>
<tr bgcolor='<{#row_color1#}>'>
<td><{$array[stu].id}></td>
<td><{insert name=getStuinfo func=name stu_id=$array[stu].id}></td>
<td><{insert name=getStuinfo func=birthday stu_id=$array[stu].id}></td>
<td><{insert name=getStuinfo func=score stu_id=$array[stu].id}></td>
<td><a href='details.php?id=<{$array[stu].id}>'>详细信息</a> </td>
</tr>
<{else}>
<tr bgcolor='<{#row_color2#}>'>
<td><{$array[stu].id}></td>
<td><{insert name=getStuinfo func=name stu_id=$array[stu].id}></td>
<td><{insert name=getStuinfo func=birthday stu_id=$array[stu].id}></td>
<td><{insert name=getStuinfo func=score stu_id=$array[stu].id}></td>
<td><a href='details.php?id=<{$array[stu].id}>'>详细信息</a> </td>
</tr>
<{/if}>
<{/section}>
</table>
<hr/>
最后的访问时间为:<{insert name=getDate }>
<br/><br/><hr/>
利用insert调用getStuinfo()查看学生的基本信息,不缓存:
<{insert name=getStuinfo stuName=$array[0]}>
</center>
</body>
</html>
stu_detail.tpl
<{config_load file="test.conf"}>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>学生详细信息</title>
</head>
<body>
<center>
<{section name=stu_detail loop=$stu_details}>
<h1><{insert name=getStuinfo func=name stu_id=$stu_details[stu_detail].id}>的详细信息</h1><hr/>
学号:<{$stu_details[stu_detail].id}><br/>
姓名:<{insert name=getStuinfo func=name stu_id=$stu_details[stu_detail].id}><br/>
生日:<{insert name=getStuinfo func=birthday stu_id=$stu_details[stu_detail].id}><br/>
成绩:<{insert name=getStuinfo func=score stu_id=$stu_details[stu_detail].id}><br/>
<{/section}>
<hr/>
最后的访问时间为:<{insert name=getDate }>
<hr/>
<input type="button" value="返回上一层" onclick="history.back()">
</center>
</body>
</html>
insert.getStuinfo.php
<?php
function smarty_insert_getStuinfo($p){
$link = mysql_connect('localhost','root','') or die("数据库连接失败!");
mysql_select_db('xsxx',$link);
mysql_query("set names utf8");
if($p['func']=='score'){
$result = mysql_query("select score from stu where id='".$p['stu_id']."'");
$value = mysql_fetch_assoc($result);
return $value[score];
}
elseif($p['func']=='name'){
$result = mysql_query("select name from stu where id='".$p['stu_id']."'");
$value = mysql_fetch_assoc($result);
return $value[name];
}
elseif($p['func']=='birthday'){
$result = mysql_query("select birthday from stu where id='".$p['stu_id']."'");
$value = mysql_fetch_assoc($result);
return $value[birthday];
}
}
?>
insert.getDate.php
<?php
function smarty_insert_getDate(){
return date('Y-d-m H:i:s',time());
}
?>
<{config_load file="test.conf"}>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>学生基本信息</title>
</head>
<body>
<center>
<h3>学生基本信息</h3>
<table bgcolor='<{#table_bgcolor#}>' border='1'>
<tr bgcolor='<{#head_color#}>'>
<th>学号</th><th>姓名</th><th>生日</th><th>成绩</th><th>详细信息</th>
</tr>
<{section name='stu' loop=$array}>
<{if $smarty.section.stu.index is odd}>
<tr bgcolor='<{#row_color1#}>'>
<td><{$array[stu].id}></td>
<td><{insert name=getStuinfo func=name stu_id=$array[stu].id}></td>
<td><{insert name=getStuinfo func=birthday stu_id=$array[stu].id}></td>
<td><{insert name=getStuinfo func=score stu_id=$array[stu].id}></td>
<td><a href='details.php?id=<{$array[stu].id}>'>详细信息</a> </td>
</tr>
<{else}>
<tr bgcolor='<{#row_color2#}>'>
<td><{$array[stu].id}></td>
<td><{insert name=getStuinfo func=name stu_id=$array[stu].id}></td>
<td><{insert name=getStuinfo func=birthday stu_id=$array[stu].id}></td>
<td><{insert name=getStuinfo func=score stu_id=$array[stu].id}></td>
<td><a href='details.php?id=<{$array[stu].id}>'>详细信息</a> </td>
</tr>
<{/if}>
<{/section}>
</table>
<hr/>
最后的访问时间为:<{insert name=getDate }>
<br/><br/><hr/>
利用insert调用getStuinfo()查看学生的基本信息,不缓存:
<{insert name=getStuinfo stuName=$array[0]}>
</center>
</body>
</html>
stu_detail.tpl
<{config_load file="test.conf"}>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>学生详细信息</title>
</head>
<body>
<center>
<{section name=stu_detail loop=$stu_details}>
<h1><{insert name=getStuinfo func=name stu_id=$stu_details[stu_detail].id}>的详细信息</h1><hr/>
学号:<{$stu_details[stu_detail].id}><br/>
姓名:<{insert name=getStuinfo func=name stu_id=$stu_details[stu_detail].id}><br/>
生日:<{insert name=getStuinfo func=birthday stu_id=$stu_details[stu_detail].id}><br/>
成绩:<{insert name=getStuinfo func=score stu_id=$stu_details[stu_detail].id}><br/>
<{/section}>
<hr/>
最后的访问时间为:<{insert name=getDate }>
<hr/>
<input type="button" value="返回上一层" onclick="history.back()">
</center>
</body>
</html>
insert.getStuinfo.php
<?php
function smarty_insert_getStuinfo($p){
$link = mysql_connect('localhost','root','') or die("数据库连接失败!");
mysql_select_db('xsxx',$link);
mysql_query("set names utf8");
if($p['func']=='score'){
$result = mysql_query("select score from stu where id='".$p['stu_id']."'");
$value = mysql_fetch_assoc($result);
return $value[score];
}
elseif($p['func']=='name'){
$result = mysql_query("select name from stu where id='".$p['stu_id']."'");
$value = mysql_fetch_assoc($result);
return $value[name];
}
elseif($p['func']=='birthday'){
$result = mysql_query("select birthday from stu where id='".$p['stu_id']."'");
$value = mysql_fetch_assoc($result);
return $value[birthday];
}
}
?>
insert.getDate.php
<?php
function smarty_insert_getDate(){
return date('Y-d-m H:i:s',time());
}
?>
相关文章推荐
- 11-16这是昨晚的 贪吃蛇 container map food snake 几个div的构造如下(功能有待实现)
- 07/11/16 资料整理
- 编程思绪,06-6-16 到 06-11-23
- 16-11-07
- 第28次Scrum会议(11/16)【欢迎来怼】
- [16-11-18]从[DHU教师排课助手]聊一下C#使用Oledb和range Cells[row,col]操作Excel
- 16-11-14总结
- 16-11-25
- 11 03 16-17 机器人
- 明天就回家过年了……
- C#利用 Face++sdk 实现wpf小程序【1】 5/11/16
- 明天就回家了
- 明天要回家了,回我阳朔
- 明天就要回家了
- [小说连载]张小庆,在路上(16)- 回家还是北京
- Daily Scrum M2 11-16
- 15-11-16 Eclipse 操作菜单汉译之 Search [搜索]
- XSS quiz 11~16解题方案
- 错误:Error:(11, 16) 错误: 不兼容的类型: CrimeListFragment无法转换为Fragment
- 【生活工具】你能带我回家么,可能明天要下雨了。