Jump to content

Recommended Posts

Posted

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>	

  • Like 1
  • Moderators
Posted

<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.

Posted

<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.

Posted (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 by Angel Air
Posted

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>

Posted

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.

Posted

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

  • 3 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...