/    Sign up×
Community /Pin to ProfileBookmark

PHP-General – Need help with dynamic php based map

I found an old php/mysql tutorial where apparently the origional author no longer is arround to answer questions or provide assistance. So I am hoping someone on these forums could help.

The below code connects to a mysql dbase gets a players current lonitude and latitude in a game and then display’s where they are located via cross hairs on a game map.

There are also 4 html form buttons on the page to enable the player to move up down left right on the map. So when I go to the page and click one of the buttons I can see the blue cross hairs move. But after a few clicks of any of the buttons the cross hairs seem not to move any further. I am not sure if its an issue with the script not having the correct map size to useas there is a “gamesize” column in the mysql that is set to 250 but when I change it to some other larger or even smaller number the map gets all messed up and the cross hairs wont move at all.

So I am hoping by chance maybe there is just a coding error

here is my code

[code=php]
//lets get the players current lat and lon location to start out at
$sqllatlon = mysql_query(“SELECT map_lati, map_long from player_profiles where pid=’$mypid'”);
$latlonrow = mysql_fetch_array($sqllatlon);
$current_lat = $latlonrow[‘map_lati’];
$current_lon = $latlonrow[‘map_long’];

//lets update the map display
$brx = – $gamesize – $current_lon + 200;
$bry = – $gamesize + $current_lat + 200;
if ($current_lat < 0) { $current_lat = $current_lat * -1 . “S”; } else { $current_lat .= “N”; }
if ($current_lon< 0) { $current_lon = $current_lon * -1 . “W”; } else { $current_lon .= “E”; }

<table cellpadding=’5′ cellspacing=’0′ border=’0′ style=’width:90px’><tr><td colspan=’2′>
<form method=’POST’ action=”><center><input type=’submit’ name=’north’ value=’North’></center></td></tr>
<tr><td>
<input type=’submit’ name=’west’ value=’West’></td><td>
<input type=’submit’ name=’east’ value=’East’></td></tr><tr><td colspan=’2′><center>
<input type=’submit’ name=’south’ value=’South’></form></center></td></tr></table>
<center>
<table style=”width:400px; height:400px; background-image:url(‘img/map/map.gif’); background-position: <?php echo “$brx”;?>px <?php echo “$bry”;?>px; background-repeat: no-repeat; border-width: 1px; border-spacing: ; border-style: outset; border-color: black; border-collapse: collapse;”>
<tr>
<td width=10 height=200 style=”border-width: 1px; padding: 0px; border-style: dashed; border-color: blue;”>
</td>
<td width=10 height=200 style=”border-width: 1px; padding: 0px; border-style: dashed; border-color: blue;”>
</td>
</tr>
<tr>
<td width=10 height=200 style=”border-width: 1px; padding: 0px; border-style: dashed; border-color: blue;”>
</td>
<td width=10 height=200 style=”border-width: 1px; padding: 0px; border-style: dashed; border-color: blue;”>
</td>
</td>
</tr>
</table>
<br />
<center>
Latitude: <?php echo “$current_lat”?><br />
Longitude: <?php echo “$current_lon”;?><br />
<br />
[/code]

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @jayreis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...