您的位置:首页 > 编程语言

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());

}

?>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: