" />
发布时间:2019-09-01 09:52:31编辑:auto阅读(2112)
<?php
require_once "../smarty/Smarty.class.php";
$smarty=new Smarty();
$smarty->template_dir="../php/tmps";
$smarty->compile_dir="../php/tmps_c";
$smarty->left_delimiter="<{";
$smarty->right_delimiter="}>";
$dsn = 'mysql:dbname=test;host=127.0.0.1';
try{
$dbh= new PDO($dsn, 'root', '123456');
}catch(PDOException $e){
echo "数据库连接失败:".$e->getMessage();
}
$dbh->exec("set names gbk");
$rs=$dbh->query("SELECT * FROM student");
$students=array();
while($row=$rs->fetch(PDO::FETCH_ASSOC)){
array_push($students,$row);
}
$db = null;
$smarty->assign("students",$students);
$smarty->display("mysql.tpl");
?>

上一篇: Ubuntu17.04下安装sublim
下一篇: centos重启网卡提示:/org/fr
51569
51154
41665
38422
32909
29882
28601
23563
23494
21843
1993°
2706°
2266°
2188°
2643°
2207°
2960°
4890°
4730°
3362°