leachus2002 Posted November 26, 2010 Share Posted November 26, 2010 Hi All, I am trying to develop an application that show's where PC's are located in an office. Basically, what I want to be able to do, is to overlay avatar-like images over a main floorplan layout, and place them in a position, depending on thier x/y co-ordinates, which would be retreived from a database. Is this possible using PHP at all? Thanks in advance Matt Quote Link to comment Share on other sites More sharing options...
intellix Posted November 26, 2010 Share Posted November 26, 2010 Yep easy peasy I think You have a big image of the floorplan with all the computers. Then you have all of the avatar like things printing out their co-ordinates on the image with CSS inline styles <div style="position:relative;"> <img src="floorplan.jpg" alt="" style="position:absolute;top:0;left:0;" /> <?php // Grab the co-ordinates from where-ever they are and then loop through each of them foreach($coords as $coord){ echo '<img src="avatar-dom.jpg" alt="" style="position:absolute; top:' . $coord['x'] . '; left:' . $coord['y'] . ';" />'; } ?> </div> This way you have the floorplan and then store the X/Y of each avatar in the database and loop through each of them placing them on top of the floorplan where needed. Quote Link to comment Share on other sites More sharing options...
leachus2002 Posted November 26, 2010 Author Share Posted November 26, 2010 Superb! Thanks for that! Can you just confirm the variable i need to put for my select statement? Would it be something like: $coord = mssql_query = "select x,y from database" <div style="position:relative;"> <img src="floorplan.jpg" alt="" style="position:absolute;top:0;left:0;" /> <?php // Grab the co-ordinates from where-ever they are and then loop through each of them foreach($coords as $coord){ echo '<img src="avatar-dom.jpg" alt="" style="position:absolute; top:' . $coord['x'] . '; left:' . $coord['y'] . ';" />'; } ?></div> Cheers Matt Quote Link to comment Share on other sites More sharing options...
intellix Posted November 26, 2010 Share Posted November 26, 2010 Superb! Thanks for that! Can you just confirm the variable i need to put for my select statement? Would it be something like: $coord = mssql_query = "select x,y from database" <div style="position:relative;"> <img src="floorplan.jpg" alt="" style="position:absolute;top:0;left:0;" /> <?php // Grab the co-ordinates from where-ever they are and then loop through each of them foreach($coords as $coord){ echo '<img src="avatar-dom.jpg" alt="" style="position:absolute; top:' . $coord['x'] . '; left:' . $coord['y'] . ';" />'; } ?></div> Cheers Matt Mmm I've not used mssql before, I use mysql but looking at the php manual I can see its just about the same I think something like this <div style="position:relative;"> <img src="floorplan.jpg" alt="" style="position:absolute;top:0;left:0;" /> <?php // Grab the co-ordinates from where-ever they are and then loop through each of them $res = mssql_query("SELECT x,y FROM database"); while ($row = mysql_fetch_array($res, MYSQL_ASSOC)) { $left = $row["x"]; $top = $row["y"]; echo '<img src="avatar-dom.jpg" alt="" style="position:absolute; top:' . $top . '; left:' . $left . ';" />'; } ?> </div> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.