5
Guys want to fill this matrix. It works but when I try to put more than one result in the same line only the last one appears. How to fix?
<h1>Mapa</h1>
<?php
$linha=0;
$coluna=0;
//preencher o mapa
//debug($planeta);
$mapa = array();
$linhas = $planeta->count();
$planeta = $planeta->toArray();
debug($planeta);
?>
<table>
<?php
for ($coluna=0;$coluna<=10;$coluna++){
echo "<tr>";
//echo $mapa[$coluna]['x']." | ".$mapa[$coluna]['y']."<br>" ;
$x = (!empty($planeta[$coluna]['coordx'])) ? $x = $planeta[$coluna]['coordx'] : $x = NULL;
$y = (!empty($planeta[$coluna]['coordy'])) ? $y = $planeta[$coluna]['coordx'] : $y = NULL;
for ($linha=0;$linha<=10;$linha++){
//$y = (!empty($planeta[$linha]['coordy'])) ? $y = $planeta[$linha]['coordy'] : $y = NULL;
echo $x." - ".$y." - Coluna ".$coluna."<br>";
if ($linha === $y && $coluna === $x){
echo "<td><a href='planetas/planeta?x=".$coluna."&y=".$linha."'>
<img src='/gm/img/game/planeta.png' height='30px' width='30px'></a>
</td>";
} else {
echo "<td><a href='planetas/planeta?x=".$coluna."&y=".$linha."'>".$coluna."|".$linha."</a></td>";
}
}
echo "</tr>";
//echo $x." | ".$y."<br>";
}
//echo count($mapa);*/
?>
</table>
Solved...
for ($i=0; $i<$count ;$i++) { 
 $mapa[$planeta[$i]['coordx']][$planeta[$i]['coordy']]['x']=$planeta[$i]['coordx'];
 $mapa[$planeta[$i]['coordx']][$planeta[$i]['coordy']]['y']=$planeta[$i]['coordy'];
}
– Felipe Moura
Because you do not add this comment as an answer and mark it as solved, it could help others in the future, besides not leaving the question open and without "answer" accepted. =)
– Florida