这是php代码:
<?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>";
?>
HTML 输出看起来像一个巨大的 ECHO 但不是正常的表,这是一个错误还是 php 中的正常输出?我是 PHP 新手,所以请多多包涵。
输出:
"; 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 ""; ?>
该循环创建了一个 10x10 的表,其中每个单元格的图像由交换机中的 SQL 查询的结果定义。