Angel Air Posted October 13, 2012 Report Share Posted October 13, 2012 Hi all I have adapted my code to show country and rank but I have a problem it shows the country fine but not the rank here is my code any help would be great thanks. <div id="box"> <div> <h2>Users Online</h2> <p> <?php $usersonline = StatsData::UsersOnline(); $guestsonline = StatsData::GuestsOnline(); ?> <h4>Pilots Online</h4> <?php $shown = array(); foreach($usersonline as $pilot) { if(in_array($pilot->pilotid, $shown)) continue; else $shown[] = $pilot->pilotid; echo "<p>"; echo '<img src="'.Countries::getCountryImage($pilot->location).'" alt="'.Countries::getCountryName($pilot->location).'" />'; echo '<img src="<?php echo $userinfo->rankimage ?>" />'; echo "{$pilot->rankimage} {$pilot->rank}"; echo " {$pilot->firstname} {$pilot->lastname}<br />"; echo "</p>"; } ?> <h4>Guests Online</h4> <p class="txt-red10">Currently <?php echo count($guestsonline);?> guest(s) visiting. </p> </div> </div> 1 Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted October 13, 2012 Moderators Report Share Posted October 13, 2012 <div id="box"> <div> <h2>Users Online</h2> <p> <?php $usersonline = StatsData::UsersOnline(); $guestsonline = StatsData::GuestsOnline(); ?> <h4>Pilots Online</h4> <?php $shown = array(); foreach($usersonline as $pilot) { if(in_array($pilot->pilotid, $shown)) continue; else $shown[] = $pilot->pilotid; echo "<p>"; echo '<img src="'.Countries::getCountryImage($pilot->location).'" alt="'.Countries::getCountryName($pilot->location).'" />'; echo '<img src="<?php echo $userinfo->rankimage ?>" />'; $rank = RanksData::getRankInfo($pilot->rank); echo '<img src="<?php echo $rank->rankimage ;?>">'. $rank->rank ; echo " {$pilot->firstname} {$pilot->lastname}<br />"; echo "</p>"; } ?> <h4>Guests Online</h4> <p class="txt-red10">Currently <?php echo count($guestsonline);?> guest(s) visiting. </p> </div> </div> This should work. Quote Link to comment Share on other sites More sharing options...
Angel Air Posted October 13, 2012 Author Report Share Posted October 13, 2012 <div id="box"> <div> <h2>Users Online</h2> <p> <?php $usersonline = StatsData::UsersOnline(); $guestsonline = StatsData::GuestsOnline(); ?> <h4>Pilots Online</h4> <?php $shown = array(); foreach($usersonline as $pilot) { if(in_array($pilot->pilotid, $shown)) continue; else $shown[] = $pilot->pilotid; echo "<p>"; echo '<img src="'.Countries::getCountryImage($pilot->location).'" alt="'.Countries::getCountryName($pilot->location).'" />'; echo '<img src="<?php echo $userinfo->rankimage ?>" />'; $rank = RanksData::getRankInfo($pilot->rank); echo '<img src="<?php echo $rank->rankimage ;?>">'. $rank->rank ; echo " {$pilot->firstname} {$pilot->lastname}<br />"; echo "</p>"; } ?> <h4>Guests Online</h4> <p class="txt-red10">Currently <?php echo count($guestsonline);?> guest(s) visiting. </p> </div> </div> This should work. Thanks will give it try. Quote Link to comment Share on other sites More sharing options...
Angel Air Posted October 13, 2012 Author Report Share Posted October 13, 2012 still does not work i just get 2 broken image icons any other ideas? Quote Link to comment Share on other sites More sharing options...
Angel Air Posted October 13, 2012 Author Report Share Posted October 13, 2012 (edited) ok so here is what i have got so far [NOTE CHANGE TO CODE] <h2>Users Online</h2> <p> <?php $usersonline = StatsData::UsersOnline(); $guestsonline = StatsData::GuestsOnline(); ?> <h4>Pilots Online</h4> <?php $shown = array(); foreach($usersonline as $pilot) { if(in_array($pilot->pilotid, $shown)) continue; else $shown[] = $pilot->pilotid; echo "<p>"; echo '<img src="'.Countries::getCountryImage($pilot->location).'" alt="'.Countries::getCountryName($pilot->location).'" />'; echo '<img src="'.RanksData::getRankInfo($pilot->rank).'" />'; echo " ($pilot->rank)<br />"; echo " {$pilot->firstname} {$pilot->lastname}<br />"; echo "</p>"; } ?> <h4>Guests Online</h4> <p class="txt-red10">Currently <?php echo count($guestsonline);?> guest(s) visiting. </p> </div> </div> This is just showing the writing (Captain) rather than the image will keep working on it but not sure where to go from here I have just added this line in echo '<img src="<?php echo $rank->rankimage ;?>">'. $rank->rank ; After echo '<img src="'.RanksData::getRankInfo($pilot->rank).'" />'; which is giving me a broken image icon Edited October 13, 2012 by Angel Air Quote Link to comment Share on other sites More sharing options...
Angel Air Posted October 13, 2012 Author Report Share Posted October 13, 2012 ok so after some messing around I have done it. Here is the code but it does need a bit more adjustment but it works <h2>Users Online</h2> <p> <?php $usersonline = StatsData::UsersOnline(); $guestsonline = StatsData::GuestsOnline(); ?> <h4>Pilots Online</h4> <?php $shown = array(); foreach($usersonline as $pilot) { if(in_array($pilot->pilotid, $shown)) continue; else $shown[] = $pilot->pilotid; echo "<p>"; echo '<img src="'.Countries::getCountryImage($pilot->location).'" alt="'.Countries::getCountryName($pilot->location).'" />'; echo '<img src="'.RanksData::getRankimage($pilot->rank).'" />'; echo " {$pilot->firstname} {$pilot->lastname}<br />"; echo "</p>"; } ?> <h4>Guests Online</h4> <p class="txt-red10">Currently <?php echo count($guestsonline);?> guest(s) visiting. </p> </div> </div> Quote Link to comment Share on other sites More sharing options...
Angel Air Posted October 13, 2012 Author Report Share Posted October 13, 2012 next question how do i go about re-sizing the image? Quote Link to comment Share on other sites More sharing options...
Sava Posted October 13, 2012 Report Share Posted October 13, 2012 In the img echo code add width="value" after the closing src tag. It will resize the image and maintain the correct proportion by adjusting the height automatically. You can do the same but with height='value'. <img src="link" width="40px"/> Im on the phone so can't write you the entire code but you get the idea. Jus watch out when using quotations marks and escape them if/when needed when using them inside a PHP statement. Quote Link to comment Share on other sites More sharing options...
Angel Air Posted October 14, 2012 Author Report Share Posted October 14, 2012 In the img echo code add width="value" after the closing src tag. It will resize the image and maintain the correct proportion by adjusting the height automatically. You can do the same but with height='value'. <img src="link" width="40px"/> Im on the phone so can't write you the entire code but you get the idea. Jus watch out when using quotations marks and escape them if/when needed when using them inside a PHP statement. thankyou it worked great Quote Link to comment Share on other sites More sharing options...
Stealthbird97 Posted November 4, 2012 Report Share Posted November 4, 2012 Any way of adding the link to the pilots profile as well. 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.