我想从我的数据库中读取所有数据,当我从控制台运行此查询时,我得到了很多结果,但是由于某种原因,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万个结果的黑客。

最佳答案

尝试这个:

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

08-06 22:20