Ja, kein Problem!
PHP-Code:
<?php
try {
$dbh = new PDO('mysql:host=localhost; dbname=sternwarte', 'root', '');
echo '<div id="puzzle">';
echo "<table border=0>";
echo '<tr>';
$stmt = $dbh->prepare("SELECT * FROM puzzle");
$stmt->execute();
$result= $stmt->fetchAll();
foreach($result as $key){
if($key[2]==1 and $key[1]>=2){
echo '</tr>';
echo '<tr>';
}
if($key[3]==''){
echo '<td class="grey" width="32" height="26">';
echo $key[1].','.$key[2];
echo '</td>';
}
else{
$id= $key[1].$key[2];
echo '<td value="'.$key[3].'" id="'.$id.'" width="32" height="26" onClick="tag(document.getElementById('.$id.').getAttribute("value"))">';
echo '<script type="text/javascript"> var td=document.getElementById('.$id.').getAttribute("value"); document.write(td);</script>';
echo '</td>';
}
}
$dbh = null;
echo '</tr>';
echo '</table>';
echo '</div>';
}
catch (PDOException $e) {
print "Error!: " . $e->getMessage() . "<br/>";
die();
}
?>
<?xml version="1.0" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Sternwarte Gönnsdorf :: Puzzle</title>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript">
<!--
function tag(name) {
alert(name);
}
//-->
</script>
</head>
<body>
</body>
</html>