" />
发布时间:2019-09-01 09:52:31编辑:auto阅读(2147)
<?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
51753
51439
41846
38620
33112
30105
28775
23771
23686
22053
90°
2284°
2978°
2484°
2422°
3035°
2433°
3239°
5342°
5159°