oK I used that code inside my index.php where for now its just the news.
Here's a pic:
PIC:
http://imageshack.us/f/813/mapqu.jpg/
And there are some problems.
Ok first, forget the "style" i fixed it after taking the print.
But there is one problem: I got only 3 villages registred and there are other ones "ghost" villages that aren't created.
I removed the /* */ from your code and added, but without the code between the comments the actual villages disappear from the map and there are only the ghosts ones...
Not sure why this is happening here's the code:
Code: Select all
<!DOCTYPE html>
<center>
<html>
<head>
<style type="text/css">
#map {
height: 600px;
width: 800px;
border: 1px dashed #000;
margin: auto;
overflow: hidden;
}
#map .village {
position: relative;
height: 50px;
width: 50px;
}
#map .village a {
height: 50px;
width: 50px;
background: #F00;
border: #F00 1px solid;
display: block;
}
</style>
</head>
<title>Village Wars</title>
<body>
<?php
include 'config.php';
session_start();
require "languages/index.lang.php";
echo "<a href='index.php'><img src='images/banner.jpg'></a>"; //Banner
?>
<link href="style.css" rel="stylesheet" type="text/css"/>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
echo "<div id='vwmain'>";
if (isset($_POST['LOGIN-NOW']))
{
$player=$_POST['player'];
$password=$_POST['password'];
$player=strip_tags($player);
$password=md5($password);
$query = "select username,password from players where username='$player' and '$password'";
$result = mysql_query($query) or die("Internal Error 432551 - Login Status: OFFLINE");
$result2 = mysql_fetch_array($result);
if ($result2)
{
$_SESSION['player']= $player;
echo '<meta http-equiv="refresh" content="0; URL=index.php"></center></div>';
}
else
{
if(isset($language))
{
echo "<h2>". $lang['LoginError1']['$language'] . "</h2>";
}
else
{
echo "<h2>" . $lang['LoginError1']['en'] . "</h2>";
}
echo '<meta http-equiv="refresh" content="2; URL=index.php">';
}
}
else
{
echo "</div>";
if (isset($_SESSION['player']))
{
$player=$_SESSION['player'];
$info=mysql_fetch_array(mysql_query("SELECT * from players where username='$player'"));
$language = $info['language'];
$gold = $info['gold'];
$username = $info['username'];
include_once "runcron.php";
include_once "runcron2.php";
}
else
{
include 'register.php';
include 'login.php';
exit;
}
}
include 'menu.php';
/*
METER ISTO EM TODAS AS PAGS:
*/
if(isset($_SESSION['player']))
{
echo '
<div id="playerinfotop"><center>
' . $lang["Username"][$language] . ' ' . $player . ' ' . $lang["Gold"][$language] . ' ' . $gold . '
</div></center>
';
include 'pub.php';
echo '<div id="igactivemenu">';
include 'news.php';
$mapDiv = '<div id="map">';
/* $villageQuery = mysql_query("SELECT * FROM `aldeias`");
while( $village = mysql_fetch_assoc($villageQuery) )
{
// village div should be aligned to center of its axes, not to the top right corner
// therefore we take half the div height and width of its position
$mapVillageX = $village['x'] - 25; // 25 = 50/2 (50px)
$mapVillageY = $village['y'] - 25; // 25 = 50/2 (50px)
$mapDiv .= '<div class="village" style="top: '. $mapVillageY .'px; left: '. $mapVillageX .'px">
<a href="village.php?x='. $village['x'] .'&y='. $village['y'] .'">Village</a>
</div>';
}
*/
// randomized example
$villageArray = array();
for( $i=0; $i<=rand(1,25); $i++ )
{
$villageArray[] = array( 'x' => rand(0,400), 'y' => rand(0,500) );
}
foreach( $villageArray as $village )
{
// village div should be aligned to center of its axes, not to the top right corner
// therefore we take half the div height and width of its position
$mapVillageX = $village['x'] - 25; // 25 is half 50 (50px)
$mapVillageY = $village['y'] - 25; // 25 is half 50 (50px)
$mapDiv .= '<div class="village" style="top: '. $mapVillageY .'px; left: '. $mapVillageX .'px">
<a href="village.php?x='. $village['x'] .'&y='. $village['y'] .'">Village</a>
</div>';
}
echo $mapDiv . '</div>';
echo '</div>';
}
?>
</body>
</html>
Your part is the last part of the code, and the igactivemenu is the area of the news and the area where the map should be displayed.
Thanks a lot for your code i see it works but just need to fix this problems.