" />
发布时间:2019-09-01 09:52:31编辑:auto阅读(2189)
<?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
51922
51690
42011
38850
33337
30311
28949
23962
23878
22247
350°
2575°
3246°
2701°
2680°
3416°
2647°
3480°
5715°
5513°