Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法从mysql获取php中的完整数组_Php_Mysql - Fatal编程技术网

无法从mysql获取php中的完整数组

无法从mysql获取php中的完整数组,php,mysql,Php,Mysql,在phpmyadmin中,我得到了预期的结果,这意味着在一段时间内每天有多少次假期,但是我无法在PHP上工作,只能得到整个数组的第一行 $mysqli = mysqli_connect("localhost", "andes", "andes123","andes"); $query= "select calendar_table.dt, count(BP) as 'Number' from calendar_table left join tbl021_vacaciones on calend

在phpmyadmin中,我得到了预期的结果,这意味着在一段时间内每天有多少次假期,但是我无法在PHP上工作,只能得到整个数组的第一行

$mysqli = mysqli_connect("localhost", "andes", "andes123","andes");
$query= "select calendar_table.dt, count(BP) as 'Number'
from calendar_table
left join tbl021_vacaciones on calendar_table.dt between
tbl021_vacaciones.fecha_inicio and tbl021_vacaciones.fecha_fin
where (calendar_table.dt between '2016-01-29' and '2016-03-31')
group by calendar_table.dt";
$request=mysqli_query($mysqli,$query);
$row=mysqli_fetch_array($request);
$Resultado= print_r ($row['dt'], $row['Number']);

我知道我做错了,但我无法将结果保存到一个PHP中以获取mysqli查询的所有行:

$rows = mysqli_fetch_all( $request, MYSQLI_ASSOC );
或:


MYSQLI\u ASSOC
表示仅作为关联数组获取。否则,您将获得数字索引和关联索引,如您的示例中所示(顺便说一句,这不是原始代码中的错误)。

要获取所有需要循环的结果,请执行以下操作:

while($row=mysqli_fetch_assoc($request)) {
 //echo $row['dt'];
}

请让你的问题清楚易懂。另外,
print_r()
print和array,这样你就可以将它编码为
print_r($row)
但是我在使用mysqliyah,我没有看到“I”我的坏:D
而($row=mysqli_fetch_assoc($request)){print_r($row)}
这就是答案!如果你不介意使用两倍的必要内存,这根本不是问题。^@riggsfully是的,你是对的。我的意思是这不是问题的关键。我会更新答案的,谢谢。
while($row=mysqli_fetch_assoc($request)) {
 //echo $row['dt'];
}