function createMatrixTable($pCaption1, $pMaxX, $pCaption2, $pMaxY, $pMasterID) { // function vars define("DBName", "test"); define("DBServer", "localhost"); define("DBUser", "htbase"); define("DBPasswd", "reichtum"); $wrongArgsError = "Argumente falsch &�bergeben, Aufruf: 1.String, 2.Int, 3.String, 4.Int 5.String \n"; // check args if (!is_string(pCaption1) or (!is_int($pMaxX)) or (!is_string($pCaption2)) or (!is_int($pMaxY)) or (!is_string($pMasterID))) { echo "$wrongArgsError"; exit; } else { // create db-conn $dbConn = mysql_connect(DBServer, DBUser, DBPasswd) or die("Keine Verbindung m&�glich: ".mysql_error()); // select db mysql_select_db(DBName) or die("Auswahl der Datenbank fehlgeschlagen"); // create initial table containing only two columns $tablename = $pCaption1 . "_" . $pMaxX ."_" . $pCaption2 . "_" . $pMaxY . "_" . $pMasterID; $queryCreateTable = "create table ". $tablename . " (" . "ID int auto_increment primary key, " . $pMasterID . " varchar(10))"; mysql_query($queryCreateTable) or die("Anfrage fehlgeschlagen create table query: ".mysql_error()); // add columns for($i = 1; $i <= $pMaxX; $i++) { for($j = 1; $j <= $pMaxY; $j++) { $colName = $pCaption1 . "_" . $i . "_" . $pCaption2 . "_" . $j; $queryAddColumn = "alter table " . $tablename . " add column " . $colName . " float;"; mysql_query($queryAddColumn) or die("Anfrage Spalte hinzufuegen fehlgeschlagen: ".mysql_error()); }   ; } mysql_close($dbConn); } }