Home  >  Article  >  Backend Development  >  php从mysql中读取表的各个字段的信息代码,

php从mysql中读取表的各个字段的信息代码,

WBOY
WBOYOriginal
2016-06-13 13:10:55861browse

php从mysql中读取表的各个字段的信息代码,求高手指教。。。
我没学过php,所以请各位高手讲详细点。。。谢谢帮忙了。。。我想通过一个sql语句搜索到某条数据,然后把这个数据记录到一个变量a中,通过调用a.name就能得到这条数据的name字段的信息了,这样能实现么?怎么实现的?

------解决方案--------------------
如果id 是唯一的。则不需要while循环,因为只有一条。则改为:
$q = "select * from test where id = 1"; //SQL查询语句
$rs = mysql_query($q,$conn); //获取数据集
$row = mysql_fetch_object($rs);
print_r($row);
echo $row->id;

mysql_free_result($rs);

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn