" />
发布时间:2019-09-01 09:52:31编辑:auto阅读(2072)
<?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
51330
50782
41377
38179
32668
29558
28398
23277
23243
21567
1649°
2379°
1983°
1924°
2251°
1957°
2653°
4446°
4279°
3049°