Zitat von Quetschi
Beitrag anzeigen

<?PHP
$con = mysqli_connect("localhost", "root", "", "test");
$sql = "SELECT user_id, x, y from t3";
$result = mysqli_query($con,$sql)
or die ("MySQL-Error: " . mysqli_error());
$data = array();
while($row = mysqli_fetch_array($result))
$data[$row['x'] . "/" . $row['y']] = $row['user_id'];
echo "<table border=0>";
for($x = 1; $x <= 10; $x++)
{
echo "<tr>";
for($y = 1;$y <= 10; $y++)
{
$key = $x . "/" . $y;
if (array_key_exists($key, $data))
{
$output = $data[$key];
$color = "green";
}
else
{
$output = $key;
$color = "red";
}
echo "<td>
<div style='float: left; width: 50px; height: 50px; margin-right: 0px; margin-bottom: 0px; background-color: $color ; text-align: center;'>$output</div>
</td>";
}
echo "</tr>";
}
echo "</table>";
?>
<?PHP $con = mysqli_connect("localhost", "root", "", "test"); $sql = "SELECT user_id, x, y, type from map"; $result = mysqli_query($con,$sql) or die ("MySQL-Error: " . mysqli_error()); $data = array(); while($row = mysqli_fetch_array($result)) $data[$row['x'] . "/" . $row['y']] = $row['user_id']; $type = $row['type']; echo "<table border=0 style=table-layout:fixed>"; for($x = 1; $x <= 30; $x++) { echo "<tr>"; for($y = 1;$y <= 50; $y++) { $key = $x . "/" . $y; if (array_key_exists($key, $data)) { $output = '';//$data[$key]; $color = "red"; } else { $output = $key; $color = "green"; } echo "<td style=width:0px;> <a href='test.php?x=$x&y=$y'><div style='width: 20px; height: 20px; margin: 0px; border: none; background-color: $color;'></div></a> </td>"; } echo "</tr>"; } echo "</table>"; ?>
<?php
echo "<table style='border: 0; border-collapse: collapse;'>";
for($x = 1; $x <= 30; $x++)
{
echo "<tr style='padding:0;'>";
for($y = 1;$y <= 50; $y++)
{
if ($y % 3)
$color = "red";
else
$color = "green";
echo "<td style='padding:0;'>
<a href='test.php?x=$x&y=$y'><div style='width: 20px; height: 20px; margin: 0px; border: none; background-color: $color;'></div></a>
</td>";
}
echo "</tr>";
}
echo "</table>";
?>
Kommentar