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
?>
当我回显$info数组它工作正常,但当我回显$player数组或$pl_1变量或$结果数组值注意出现…数组到字符串转换和o / p不显示.
为什么?
最佳答案
尝试替换$player [] = array(); by $player = array();在开头(第2行).
这是因为你在这个变量的索引0处声明了一个数组,由于[],它被告知是一个数组.因此,您尝试在数组中放置一个数组,使其成为多维数组.
猜你在找的MySQL相关文章