" />
发布时间:2019-09-01 09:52:31编辑:auto阅读(2139)
<?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
51675
51333
41766
38545
33020
30039
28709
23692
23612
21974
2161°
2864°
2387°
2329°
2869°
2340°
3129°
5137°
4967°
3546°