Angel Air Posted October 13, 2012 Report 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
Moderators Parkho Posted October 13, 2012 Moderators Report 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
Angel Air Posted October 13, 2012 Author Report 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
Angel Air Posted October 13, 2012 Author Report Posted October 13, 2012 still does not work i just get 2 broken image icons any other ideas? Quote
Angel Air Posted October 13, 2012 Author Report 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
Angel Air Posted October 13, 2012 Author Report 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
Angel Air Posted October 13, 2012 Author Report Posted October 13, 2012 next question how do i go about re-sizing the image? Quote
Sava Posted October 13, 2012 Report 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
Angel Air Posted October 14, 2012 Author Report 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
Stealthbird97 Posted November 4, 2012 Report Posted November 4, 2012 Any way of adding the link to the pilots profile as well. Quote
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.