<?php
$player[] = array();
$team_id = $_SESSION['tid'];
$team_pids = $con->prepare("SELECT p_id FROM players_to_team WHERE t_id = ?");
$team_pids->bindParam(1,$team_id);
$team_pids->execute();
while($info = $team_pids->fetch(PDO::FETCH_ASSOC))
{
$player[] = $info['p_id'];
echo $info['p_id'];
}
$pl_1 = $player[0];
.
.
.
$pl_10 = $player[9];
echo $player[0]; //notice here
echo $pl_1; //notice here
?>
<table>
$query = $con->prepare("SELECT role,name,value FROM players WHERE p_id = '".$pl_1."'");
// notice here
$query->execute();
while($result = $query->fetch(PDO::FETCH_ASSOC))
{
echo "<tr>";
echo "<td>".$result['role']."</td>";
echo "<td>".$result['name']."</td>";
echo "<td>".$result['value']."</td>";
}
?>
</tr>
</table>
当我回显 $info 数组时,它工作正常,但是当我回显 $player 数组或 $pl_1 变量或 $result 数组值时,会出现通知...数组到字符串转换,并且 o/p 不显示。
为什么?
尝试更换$player[] = array();
by $player = array();
在开头(第 2 行)。
这是因为您在该变量的索引 0 处声明了一个数组,该变量被告知是一个数组,因为[]
。因此,您尝试在数组中放置一个数组,使其成为多维的。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)