select("id", "map", "WHERE name='" . $_POST['file'] . "'"); if (!$result['id']) //map file name wasn't found in the database $id = $database->insert("map", "name", "'" . $_POST['name'] . "'"); //add a map with this file name else $id = $result['id']; //we found the right id with the database select //now we update or add all the data from the map for ($i = 0; $i <= height($map); $i++) for ($j = 0; $j <= width($map); $j++) { //see if this row is already in the database $result = $database->select("id", "mapdata", "WHERE mapid=$id AND x=$i and y=$j and z=" . $_POST['level'] . ""); //we found this row already in the database, so just update it if ($result['id']) $database->update("mapdata", "value='" . $map[$i][$j] . "'", "WHERE mapid=$id and x=$i and y=$j and z=" . $_POST['level'] . ""); else //we haven't found a row like this $database->insert("mapdata", "x, y, z, value, mapid", "'$i', '$j', '" . $_POST['level'] . "', '" . $map[$i][$j] . "', '$id'"); } $error = "Map has been added or updated!"; } ?> Pits of Doom -- Map File Database Importer
Map File Database Importer

"; ?>
Map Name:

Level: