EchoFool Posted January 6, 2009 Share Posted January 6, 2009 Im making a GPS system for practice....and I have a while loop that is creating a map of images.. followed by loading an image on the map tile where the person is with their boat. But its acting v.odd... like the first row is non existent and the last row is out of the table completely which makes no sense.... have attatched two pictures to show you what i mean but this is my while loop also: <div class=tablecenter2> <table width="700" border="1" cellspacing="0" cellpadding="0" align="center"> <?php //load where the person is If(!(isset($_GET['x']))){ $X = 0; }Else{ $X = $_GET['x']; } If(!(isset($_GET['y']))){ $Y = 0; }Else{ $Y = $_GET['y']; } //keep equal number of rows shown when at edge of map If($Y < 5){ $var4 = 6 - $Y + 4; }Else{ $var4 = 5; } If($Y > 20){ $var5 = 4 - (20-$Y); $var5 = 5 + $var5; }Else{ $var5 = 5; } //load 4 tiles up and down from your position $Get = mysql_query("SELECT Y FROM explore WHERE (Y>($Y-$var5) AND Y<($Y+$var4)) GROUP BY Y ORDER BY Y ASC") Or die(mysql_error()); //Y while loop While($row = mysql_fetch_assoc($Get)){ Echo '<tr>'; //keep equal number of columns shown when at edge of map If($X < { $var3 = 8 - (3 + $X); $var3 = 5 + $var3; }Else{ $var3 = 4; } If($X > 22){ $var2 = 4 - (25-$X); $var2 = 4 + $var2; }Else{ $var2 = 5; } //load 4 tiles left and right from your position $Get2 = mysql_query("SELECT Image,X FROM explore WHERE (X>($X-$var2) AND X<($X+$var3)) AND Y={$row['Y']} ORDER BY X ASC") Or die(mysql_error()); //X while loop While($row2 = mysql_fetch_assoc($Get2)){ //show the map tile and place it in a div withing a td with an image set with a z-index of 2 call name "x" ?> <td width=90 height=50> <div style="width:90px;height:50px;"> <img class="x" src="<?=$row2['Image']?>" width=90 height=50 alt="X:<?=$row2['X']?> Y:<?=$row['Y']?>"> <?php //check if the tile loaded is where You are if so load a image of a boat on the map with a high priority z-index which is class name zindex If($row2['X'] == $X && $row['Y'] == $Y){ ?> <div id=test> <br> <p align=center> <a class="zindex" href="med.php?x=<?=$row2['X']?>&y=<?=$row['Y']?>#test"> <img class="" src="../images/images2/boat.gif" width=25 height=25></a> </p> <br> </div> <?php } //end of checking if same tile as location ?> </td> <?php } //end X while loop }//end Y while loop ?> </table> </div> From my two pictures you can see a mis-alignment of rows by one row, one from the top is missing yet the image loads but the boat doesnt load on it and theres an extra one some how pushing out of the table altogether. But yet the tiles are not loading where the boat goes out of the table.. but they do for the top row yet the boat won't display in to it... So any one got any ideas.. also could some one test this to see you get same problem with script... [attachment deleted by admin] Link to comment https://forums.phpfreaks.com/topic/139757-solved-gps-system-loop-mis-alignment/ Share on other sites More sharing options...
EchoFool Posted January 6, 2009 Author Share Posted January 6, 2009 Turned out i fixed it:) Link to comment https://forums.phpfreaks.com/topic/139757-solved-gps-system-loop-mis-alignment/#findComment-731195 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.