Code: Select all
function getMap()
{
$.ajax({
url : 'scripts/php/getMap.php',
type : 'POST',
data : {mapR:mapR,mapC:mapC,zone:zone
},
dataType:'json',
success : function(data) {
buildMap(data);
}
});
}
function buildMap(data)
{
var map = document.getElementById("map");
///.innerHTML will end all div tags so must do a string builder
var mapDiv = "";
var counter = 0;
for(var i = 0; i < 25; i++)
{
if(counter == 5)
{
mapDiv += "<div id='grid" + i + "' class='breakGrid grid'>";
innerCounter = 0;
for(var m = 0; m < 9; m++)
{
var backgroundPic = parseMapBackground(data[i],m);
var foregroundPic = parseMapForeground(data[i],m);
if(innerCounter == 3)
Also second question, is that I plan to use many if statments based off what my mysql has in it for activities to build my screen, is there a better way than using many if statments?
Example of what I plan:
Code: Select all
if (data.zone==1){if (data.region==1){if (data.activities == 7) {build activity 7}if(data.activities == 3) {build activities 3}}} etc
For those not familiar with mmotutorial 2.0, here is the getmap()
Code: Select all
<?php
include 'DbClass.php';
$db = new Db();
$zone = $_POST['zone'];
$mapR = $_POST['mapR'];
$mapC = $_POST['mapC'];
$mapRMin = $mapR - 2;
$mapCMin = $mapC - 2;
$mapRMax = $mapR + 2;
$mapCMax = $mapC + 2;
$rows = $db -> select("select * from maps where zone='" . $zone . "' and (mapR >= " . $mapRMin . " and mapR <= " . $mapRMax . ") and (mapC >= " . $mapCMin . " and mapC <= " . $mapCMax . ")");
if($db->error() != '')
{
$error = $db->error();
$db -> close();
echo json_encode($error);
}
else
{
$db -> close();
echo json_encode($rows);
}
?>