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 Link to comment https://forums.phpfreaks.com/topic/219883-php-to-show-images-on-page-depending-on-co-ordinates/ 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. Link to comment https://forums.phpfreaks.com/topic/219883-php-to-show-images-on-page-depending-on-co-ordinates/#findComment-1139846 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 Link to comment https://forums.phpfreaks.com/topic/219883-php-to-show-images-on-page-depending-on-co-ordinates/#findComment-1139848 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> Link to comment https://forums.phpfreaks.com/topic/219883-php-to-show-images-on-page-depending-on-co-ordinates/#findComment-1139865 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.