select("id", "map", "WHERE name='" . $_SESSION['name'] . "'"); if (!$result['id']) //map file name wasn't found in the database $id = $database->insert("map", "name", "'" . $_SESSION['name'] . "'"); //add a map with this file name else $id = $result['id']; //we found the right id with the database select for ($i = 0; $i <= $_SESSION['height']; $i++) { for ($j = 0; $j <= $_SESSION['width']; $j++) { //if this map already exists then update this row //otherwise insert this as a new row //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=" . $_SESSION['level'] . ""); //we found this row already in the database, so just update it if ($result['id']) $database->update("mapdata", "value='" . $_POST[$i . "_" . $j] . "'", "WHERE mapid=$id and x=$i and y=$j and z=" . $_SESSION['level'] . ""); else //we haven't found a row like this $database->insert("mapdata", "x, y, z, value, mapid", "'$i', '$j', '" . $_SESSION['level'] . "', '" . $_POST[$i . "_" . $j] . "', '$id'"); } } $error = "Map changes saved!"; unset($_SESSION); unset($_POST); } if ($_POST['reset']) unset($_SESSION); if ($_POST['startmap']) //start creating our map, setup our map variables { if (!$_POST['width'] || $_POST['width'] <= 0) $error = "This map must have a valid width."; else $_SESSION['width'] = $_POST['width']; if (!$_POST['height'] || $_POST['height'] <= 0) $error = "This map must have a valid height."; else $_SESSION['height'] = $_POST['height']; if (!$_POST['name']) $_SESSION['name'] = "Default Map"; else $_SESSION['name'] = $_POST['name']; if (!$_POST['level']) $_SESSION['level'] = 1; else $_SESSION['level'] = $_POST['level']; } if (!$_POST['export']) { ?> Pits of Doom - Map Editor >
Map Settings Alert: $error

"; ?>
Name:

Level:

Width:

Height:
Creating Map For " . $_SESSION['name'] . " Level " . $_SESSION['level'] . "
Dimensions: " . $_SESSION['width'] . " X " . $_SESSION['height'] . "

"; echo "
"; //does this look familiar?!? for ($i = 0; $i < $_SESSION['width']; $i++) echo ""; echo ""; for ($i = 0; $i < $_SESSION['height']; $i++) { echo ""; for ($j = 0; $j < $_SESSION['width']; $j++) { echo ""; } echo ""; } echo "
$i
$i
"; } ?>