Home > Backend Development > PHP Tutorial > PHP怎么将数据库表的列值赋值给数组

PHP怎么将数据库表的列值赋值给数组

WBOY
Release: 2016-06-13 13:15:08
Original
1413 people have browsed it

PHP如何将数据库表的列值赋值给数组?
$myquery=@mysql_query("select * from db_select")
or die("查询语句执行失败!");
$cnt=mysql_num_rows($myquery);
for($i=0;$iecho "" . mysql_result($myquery,$i,0) ."";

}
现在 mysql_result中保存了数据库0列所有的值,请问如果我想把mysql_result中的内容赋值给一个数组$arr应该如何操作?

还有我觉得 mysql_result($myquery,$i,0)这个形式太麻烦了,可不可以直接从查询语句下手,
$myquery=@mysql_query("select 我所需要的列 from db_select"),然后把 mysql_result($myquery,$i,0)简化成mysql_result($myquery,$i)?

PHP新手,希望高手解答。

------解决方案--------------------
mysql_fetch_array
------解决方案--------------------
while ($row = mysql_fetch_array($result)) {
$newarray = $row
}

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template