prepare("select id,ztname,zttype,zttime,headimg,riseimg fro"/> prepare("select id,ztname,zttype,zttime,headimg,riseimg fro">
如何在function里操作pdo呀
代码如下
require("../inc/pdo.php");<br /><br />function output($action,$select,$name){<br />$select=$dbc->prepare("select id,ztname,zttype,zttime,headimg,riseimg from naszt where 1=1 and zttype=:zttype");<br />$select->bindValue(":zttype",$action);<br />$select->execute();<br />$result='';<br />while($row=$select->fetch()){<br />$result.='<ul id="thumbs"><li class="'.$name.'">';<br />$result.='<div class="img-container">';<br />$result.='<div class="item-img">';<br />$result.='<img src="ztImg/'.$row['riseimg'].'" style="max-width:90%"怎么在function里操作pdo呀" ></div><ul>';<br />$result.='<li><a href="portfolio-single.html" class="view">测试1</a></li>';<br />$result.='<li><a href='.$row['headimg'].' class="preview" data-rel="prettyPhoto[web]">测试12</a></li></ul></div><div class="item-info">';<br />$result.='<h3 class="title">'.$row['ztname'].'</h3>';<br />$result.='<span class="category">'. $row['zttype'].'</span>'; <br />$result.='<p class="intro">1推荐日期:'.$row['zttime'].'</p></div></li>';<br /> }<br />return $result;<br />}
<?php<br />header("Content-Type:text/html;charset=utf-8");<br />$dbtype='mysql';<br />$host='127.0.0.1';<br />$dbName='nas';<br />$user='227227';<br />$pass='227227';<br />$db="$dbtype:host=$host;dbname=$dbName";<br />try{<br />$dbc=new PDO($db,$user,$pass);<br />$dbc->exec('SET CHARACTER SET utf8');<br />$dbc->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); //禁用prepared statements的仿真<br /> }catch(PDOException $e){<br />echo $e->getMessage();<br />}<br />?>