我正在尝试从表中获取匹配的行并将其保存在全局数组中,以便我可以在不同的函数中使用它。
但是当我对该数组执行 print_r
时,它只显示最后一行。
这是我的代码
function setCampoFeed()
{
echo $sql = "SELECT campofeed.tag,campofeed.registro,campofeed.valor FROM campofeed ".
"INNER JOIN registrofeed ON registrofeed.id = campofeed.registro ".
"WHERE registrofeed.feed='".$this->idFeed."'";
$result= $this->localDb->execute($sql);
$this->campoFeed= mysql_fetch_array($result))
}
所以这里 campoFeed
是应该包含匹配的所有行的数组,但现在它只有最后一行。
提前致谢
最佳答案
使用
$this->campoFeed[] = mysql_fetch_array($result);"
已安装
$this->campoFeed= mysql_fetch_array($result);
您将获得数组中的所有数据
关于php - 如何从 PHP 数组中的 Mysql 表中获取所有匹配的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29160979/