Here is the php code:
<?php
require_once('../phpFunctions/funciones.php');
conectar('localhost', 'root', '*******', 'tutoriales');
echo "<table cellspacing=\"0\" border=\"1\" cellpadding=\"0\">";
for ($x = 0; $x <= 9; $x++) {
echo "<tr>";
for ($y = 0; $y <= 9; $y++) {
$numero = $x."".$y;
$region = (int)$numero;
$sentencia = @mysql_query('select type,region from tutorial1_estrellas where region='.$region.'');
$lanzar = @mysql_fetch_object($sentencia);
if($lanzar[1]==$region){
switch ($lanzar[0]) {
case "red":
echo "<td><img src=\"../images/redRegion.png\"></td>";
break;
case "yellow":
echo "<td><img src=\"../images/yellowRegion.png\"></td>";
break;
case "blue":
echo "<td><img src=\"../images/blueRegion.png\"></td>";
break;
}
} else
echo "<td><img src=\"../images/voidRegion.png\"></td>";
}
echo "</tr>";
}
echo "</table>";
?>
The HTML output looks like a huge ECHO but not a normal table, is this an error or this is normal output in php? I'm new to PHP so please bear with me.
OUTPUT:
"; for ($x = 0; $x "; for ($y = 0; $y if($lanzar[1]==$region){ switch ($lanzar[0]) { case "red": echo ""; break; case "yellow": echo ""; break; case "blue": echo ""; break; } }else echo ""; } echo ""; } echo ""; ?>
The loop makes a 10x10 table where the images of each cell are defined by the result of the SQL query in the switch.