/************** Retrieving Data from database ****************/
$sql = "SELECT * FROM user_pokemon_db WHERE user_id = '17' AND team != '0'";
$res = mysql_query($sql);
$i = 0;
while($rows = mysql_fetch_assoc($res))
{
$bpkmn_id[$i] = $rows['pkmn_id'];
$battle_level[$i] = $rows['level'];
$battle_health[$i] = $rows['health'];
$path = mysql_query(" SELECT * FROM pokemons WHERE pk_id = '".$bpkmn_id[$i]."' ");
$battle_poke[$i] = mysql_result($path,0,"path");
$i++;
}
$i = 0; /******** Storing retrieved data in Multidimensional array ***********/
while($i <= 5)
{
$battlepokemons = array
(
$pokemon[$i] = array('battle_poke' => $battle_poke[$i], 'battle_level' => $battle_level[$i], 'battle_health' => $battle_health[$i])
);
$i++;
}
我首先检索数据然后将其存储在多维数组中! 现在我要显示它!我尝试了自己...并尝试使用Stackoverflow解决方案, 但没有发现任何可以解决我的问题。
我只是想知道如何显示它,只需要一个完美的代码我的代码!
答案 0 :(得分:0)
只需使用foreach()两次
<?php
$battlepokemons = array
(
$pokemon[$i] = array('battle_poke' => $battle_poke[$i], 'battle_level' => $battle_level[$i], 'battle_health' => $battle_health[$i])
);
foreach($battlepokemons as $me)
{
$test= $me;
foreach($test as $me1)
{
echo $me1;
}
}
我希望这有助于你