从SQL在阵列中存储数据 [英] Storing data from SQL in array
本文介绍了从SQL在阵列中存储数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从我的SQL数据库中的数据存储到一个数组。目前,我有这样的:
I am trying to store the data from my sql database into an array. Currently I have this:
$query = mysql_query("SELECT * FROM `InspEmail` WHERE `Company` LIKE '$company'");
while($row = mysql_fetch_array($query))
{
$inspector = $row['name'];
}
问题是,我有8行数据。我需要从数据库中每8名存储到一个数组。当我尝试这样的:
The problem is that I have 8 rows of data. I need to store each 8 names from that database into an array. When I try this:
$inspector = array($row['name']);
这是行不通的。
推荐答案
你想要的是:
$inspector[] = $row['name'];
这会将所有8名存储类似于数组:
This will store all 8 names in an array similar to:
array(
[0] => name1
[1] => name2
[2] => name3
)
这篇关于从SQL在阵列中存储数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文