当前位置:Gxlcms > PHP教程 > PHPPDO查询如何返回单挑记录

PHPPDO查询如何返回单挑记录

时间:2021-07-01 10:21:17 帮助过:10人阅读

如:select name from user where id = 1
如何获取 name 这个值 怎么办?只有一条数据,


回复讨论(解决方案)

$conn = mysql_connect("localhost","root","");mysql_select_db("mydatabases",$conn);$result = mysql_query("select name from user where id = 1");while ($row = mysql_fetch_array($result)){    echo $row['name'];}

$db = new PDO($dsn, $user, $pass);$rs = $db->query($sql);$a = $rs->fetch(PDO::FETCH_ASSOC);

$db = new PDO($dsn, $user, $pass);$rs = $db->query($sql);$a = $rs->fetch(PDO::FETCH_ASSOC);


活捉版主一只,以后有很多问题就找你了

人气教程排行