Also hier die aktualisierte und (hoffentlich) auch lesbarere Fassung:
css: #x {padding:0px; width:10px; height:10px; table-layout:fixed}
<table style="border-collapse:collapse; float:left; margin-left:1em">
<?php
//---------------------- roter Farbbalken -----------------------
for ($rr = 255; $rr >= 0; $rr = $rr-15) {
if (strtoupper(str_pad(dechex($rr),2,"0",STR_PAD_LEFT)) === "$r") {
$contrast = 255-$rr;
echo("<tr>
<td id="x"
style="border:2px solid #".str_pad(dechex($contrast),2,"0",STR_PAD_LEFT)."FFFF;
width:6px;
background-color:#".str_pad(dechex($rr),2,"0",STR_PAD_LEFT)."0000">
<a style="font-size:10px"
href="admin.php?c=$c&r=$r">
</a>
</td>
</tr>\n");
} else {
echo("<tr>
<td id="x"
style="background-color:#".str_pad(dechex($rr),2,"0",STR_PAD_LEFT)."0000">
<a style="font-size:10px"
href="admin.php?c=$c&r=".strtoupper(str_pad(dechex($rr),2,"0",STR_PAD_LEFT))."">
</a>
</td>
</tr>\n");
}
}
echo("</table>\n");
//------------------- grüner Farbbalken -----------------------
[...]
//------------------- rote Farbtabelle -----------------------
echo("<table style="border-collapse:collapse; float:left; margin-left:1em">\n");
if ("$r" <> "") {
$rr = "$r";
for ($gg = 255; $gg >= 0; $gg = $gg-15) {
echo("<tr>\n");
for ($bb = 0; $bb < 256; $bb = $bb+15) {
echo("<td id="x"
style="background-color:#".str_pad($rr,2,"0",STR_PAD_LEFT)
.str_pad(dechex($gg),2,"0",STR_PAD_LEFT)
.str_pad(dechex($bb),2,"0",STR_PAD_LEFT)."">
<a style="font-size:10px"
href="admin.php?c=".strtoupper(str_pad($rr,2,"0",STR_PAD_LEFT)
.str_pad(dechex($gg),2,"0",STR_PAD_LEFT)
.str_pad(dechex($bb),2,"0",STR_PAD_LEFT))
."&r=$r&g=$g&b=$b">
</a>
</td>\n");
}
echo("</tr>\n");
}
//------------------- grüne Farbtabelle -----------------------
[...]
//--------------- ansonsten rote Farbtabelle ------------------
} else {
$rr = "00";
for ($gg = 255; $gg >= 0; $gg = $gg-15) {
echo("<tr>\n");
for ($bb = 0; $bb < 256; $bb = $bb+15) {
[...]
?>
</table>