<?
include_once ("../inc/db.php");
$db = new db($fehler);
$Kord=($_POST['Kordinaten']);
$Kor = explode("-", $Kord);
echo "v".$Kor[0];
echo "h".$Kor[1]."<br>";
$H = 50;
$V = 50;
$wg = 'wg';
$template = <<<HTML
<td width="15" height="15" style=" font-size:9" style="color:%s"><form id="Feld%s" action="{$_SERVER['PHP_SELF']}" method="post" onclick="this.submit()"><INPUT class="input" type="hidden" name="neu" value="{$wg}"><INPUT class="input" type="hidden" name="Kordinaten" value="%s">%s</form></td>
HTML;
// Beispieldaten werden generiert
$start = microtime(true);
$Sql_allmap="Select V,H,F_artid,Weg from map1 order by V,H";
$db->query($Sql_allmap);
$daten=0;
while ($db->next_record()) {
$records[]= array(
'V'=>(integer)$db->r("V"),
'H'=>(integer)$db->r("H"),
'weg'=>$db->r("Weg"),
'F_artid'=>$db->r("F_artid")
) ;
$daten++;
}
echo '<p>Beispieldaten generieren: '.(microtime(true)-$start).' Sekunden</p>';
// Spielfeld wird generiert
$start = microtime(true);
$fetch = true;
$i = 0;
echo '<table border="1">';
for( $coordY=0; $coordY<$V; $coordY++ ) {
echo '<tr>';
for( $coordX=0; $coordX<$H; $coordX++ ) {
if( $fetch ) {
$record = $records[$i++];
$fetch = false;
}
if( $record['V'] == $coordY && $record['H'] == $coordX ) {
printf(
$template,
($record['Weg'] === 'j' ? 'yellow' : 'gray'),
$coordX.'-'.$coordY,
$coordX.'-'.$coordY,
$record['F_artid']
);
$fetch = true;
} else { ?>
<td width="15" height="15" style=" font-size:9" style="color:%s">
<form id="Feld<?=$coordX.'-'.$coordY; ?>" action="{$_SERVER['PHP_SELF']}" method="post" onclick="this.submit()">
<INPUT class="input" type="hidden" name="neu" value="{$wg}">
<INPUT class="input" type="hidden" name="Kordinaten" value="<?=$coordX.'-'.$coordY; ?>"></form></td>
<? }
}
echo '</tr>';
}
echo '</table>';
echo '<p>Spielfeld generieren: '.(microtime(true)-$start).' Sekunden</p>';