Hey i'm trying to create a map for a game. I didn't know where to put this as this thread will handle HTML, CSS, JS, PHP, MYSQL and AJAX.

My experience, (just to show how much i can or can't do)
HTML and CSS : I know a lot about these languages.
PHP, MySql : I wrote the whole item database for my game, currently you can buy/sell items, put them in your backpack or stash, equip them, sort them by amount, name, type etc. this was a lot of repeating code and theres is still a lot to learn for me.
JS: i did a couple of tutorial and wrote a script to move an object around in a div.... thats pretty much it
AJAX: i just finished my first tutorial about how to work with JS, PHP and AJAX to sent and get a query from a DB.

So i have set up a testing database to run some tests on how to get this to work for me. The end result for this test should make the map rebuild with AJAX after the player moves a square. There is not much info about how to exactly do this with HTML, Javascript, PHP, mysql and AJAX so i'd like to open this thread in the hopes i am able to pull this off with some help. If i (we ) pull this off i will post all the code needed for this small testing environment so everyone can learn from it. After that i can get on with my bigger project that needs a map like this. Off course if there is a comprehensive tutorial about how to do this i'd be glad to read that .

So i started making a query to get the tiles i need to draw in an array. Then with a foreach loop i can generate divs with the corresponding options and picture.

The current problem is, the query i got here just returns the tileID of the current position. I expect the query to give me 9 values (the current tile the player is on and all the tiles next to him (a 3x3 grid)). It's probably something very simple i just can't think of atm .

PHP Code:
$xpos 3//this variable should get feeded by a $_GET or $_POST or something.
$ypos 3//this variable should get feeded by a $_GET or $_POST or something.

//build query
$mapquery mysql_query ("
            (xpos BETWEEN '
$xpos - 1' AND '$xpos + 1')
            (ypos BETWEEN '
$ypos - 1' AND '$ypos + 1')
) or die (mysql_error());

$mapgen mysql_fetch_assoc($mapquery);

print_r ($mapgen);  //this only gives me the tile i'm currently on ->   Array ( [tileID] => 2 ) 
I have build my table "world" like this:
systemID -> not really used yet as there is just 1 system.
orderID -> dunno if i really need this one as i could probably order my table from the xpos and ypos.
tileID -> refers to the primary key of the table where i store my tiles.

I have filled this table with 25 rows to represent a 5x5 grid. where all the outer tiles are 3 (water) the middle tile (3,3) is 2 (desert) and the rest are 1 (grass).