gpt4 book ai didi

PHP 只从 mysql 查询返回一个结果 - mysql 控制台返回几十个

转载 作者:太空宇宙 更新时间:2023-11-03 12:13:39 25 4
gpt4 key购买 nike

我想从我的数据库中读取所有数据,当我从控制台运行这个查询时,我得到了很多结果,但由于某种原因 php 只读取了一个。

$query = "
SELECT b.raw as 'address', a.raw as 'name', c.TouchTime as 'time'
FROM touchName a, touchHome b, trackTouch c
WHERE a.raw like \"%{$name}%\"
AND c.AgentID = 1
AND a.relations = b.relations
AND b.relations = c.relations
AND a.relations = c.relations
ORDER BY time desc
";

//So we can double check in the console
echo $query . "<br><br>";

$result = mysqli_query($mc, $query);

$array = mysqli_fetch_assoc($result);

//says there is only one row
$total = count( mysqli_num_rows($result) );
echo $total."<br>";

我尝试了多种方法将数据从结果中分离出来,我以多种方式修改了查询,使用分组依据、计数等尝试将其分离出来。

加入也很新,所以如果这很难看,那是因为这是第一个没有吐出 1200 万个结果的 hack。

最佳答案

试试这个:

$array = array();
while ($row = mysql_fetch_assoc($result)) {
$array[] = $row;
}

关于PHP 只从 mysql 查询返回一个结果 - mysql 控制台返回几十个,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23132075/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com