Jump to content

Recommended Posts

Posted

G'day guys,

Im trying to call a certain amount of an aircraft for my new fleet page.

I need some guidance in doing this as im not quite sure what the syntax is for echoing an amount of something.

This is what im trying to do

<?php if $aircraft->icao; == DH8 echo $amount ?>

Any guidance would be great :)

Tylor

  • Moderators
Posted

G'day guys,

Im trying to call a certain amount of an aircraft for my new fleet page.

I need some guidance in doing this as im not quite sure what the syntax is for echoing an amount of something.

This is what im trying to do

<?php if $aircraft->icao; == DH8 echo $amount ?>

Any guidance would be great :)

Tylor

Try this


<?php

if($aircraft->name == DH8)
{
	echo $amount ;
}

?>

Posted

Try this


<?php

if($aircraft->name == DH8)
{
	echo $amount ;
}

?>

Thanks Parkho for the help, however i get a blank space where i am trying to display the number.

I also tried replacing name with icao in your code, but that didn't seem to help either.

Tylor

  • Moderators
Posted

Thanks Parkho for the help, however i get a blank space where i am trying to display the number.

I also tried replacing name with icao in your code, but that didn't seem to help either.

Tylor

Your code was written wrong, so I just corrected it for you not knowing what you're trying to pull out. If you can post the entire codes for that fleet page of yours, then we can see where the problem is and fix it for you. smile.gif

Posted

Your code was written wrong, so I just corrected it for you not knowing what you're trying to pull out. If you can post the entire codes for that fleet page of yours, then we can see where the problem is and fix it for you. smile.gif

Ahh ok, i thought using $amount was the correct way of calling the number of that type of plane in my fleet, i take it there is more to it than what i put in my first post ?

That's all the code i had, as i thought it was all i needed ;)

Thats all i have to show you, the rest of the page is irrelevant

Tylor

  • Moderators
Posted

Ahh ok, i thought using $amount was the correct way of calling the number of that type of plane in my fleet, i take it there is more to it than what i put in my first post ?

That's all the code i had, as i thought it was all i needed ;)

Thats all i have to show you, the rest of the page is irrelevant

Tylor

Are you using any add-on for the fleet page? if yes, then we can write a little piece to pull out the number of fleet.

here is an add-on that I'm using:

http://forum.phpvms.net/topic/1522-fleet-table

  • Moderators
Posted

No worries

Okay. Now we're talking, so you want to show how many aircraft of a certain type you got in your fleet? or please explain what exactly do you want to show in fleet page?

Posted

Okay. Now we're talking, so you want to show how many aircraft of a certain type you got in your fleet? or please explain what exactly do you want to show in fleet page?

That's what i'm trying to do ;) I want to show an amount of a particular aircraft

Tylor

  • Moderators
Posted

That's what i'm trying to do ;) I want to show an amount of a particular aircraft

Tylor

<?php
$amount = OperationsData::getAircraftByName(DH8);
foreach($aircrafts as $aircraft)
{
if($aircraft->name == DH8)
{

       echo $amount ;
}
}
?>



Try this. But I haven't tested it.

Posted

<?php
$amount = OperationsData::getAircraftByName(DH8);
foreach($aircrafts as $aircraft)
{
if($aircraft->name == DH8)
{

       echo $amount ;
}
}
?>

Try this. But I haven't tested it.

G'day Parkho,

Just gave it a shot, but i got this:

Warning: Invalid argument supplied for foreach() in /home/qantasvi/public_html/lib/skins/brilliancev1/a.tpl on line 244

I tried changing it to

foreach($fleet as $aircraft)

but that just gave me a blank space again

regards

Tylor

  • Moderators
Posted

G'day Parkho,

Just gave it a shot, but i got this:

Warning: Invalid argument supplied for foreach() in /home/qantasvi/public_html/lib/skins/brilliancev1/a.tpl on line 244

I tried changing it to

foreach($fleet as $aircraft)

but that just gave me a blank space again

regards

Tylor

change the $aircrafts to $allaircrafts, I think that might be it.

  • Moderators
Posted

Wait!

<?php
$amount = OperationsData::getAircraftByName(DH8);
foreach($fleet as $aircraft)
{
if($aircraft->name == "DH8")
{

       echo $amount ;
}
}
?>

Try this

  • Moderators
Posted

Okay here you go:

<?php 
foreach ($fleet as $aircraft) 
     	{
      		$amount = OperationsData::getAircraftByName($aircraft->name);

           	echo count($amount) ;
     	}
?>

Now if you want to put that in the table then

<?php 
foreach ($fleet as $aircraft) 
     	{
      		$amount = OperationsData::getAircraftByName($aircraft->name);
?>
         	<tr><td align="center"><?php  echo count($amount)  ;?></td></tr>
<?php
     	}
?>

Tested and working. wink.gif

Posted

Okay here you go:

<?php 
foreach ($fleet as $aircraft) 
     	{
      		$amount = OperationsData::getAircraftByName($aircraft->name);

           	echo count($amount) ;
     	}
?>

Now if you want to put that in the table then

<?php 
foreach ($fleet as $aircraft) 
     	{
      		$amount = OperationsData::getAircraftByName($aircraft->name);
?>
         	<tr><td align="center"><?php  echo count($amount)  ;?></td></tr>
<?php
     	}
?>

Tested and working. wink.gif

I must be missing something that this code needs because i get: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

  • Moderators
Posted

I must be missing something that this code needs because i get: 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

how many a/c do you have?

  • Like 1
Posted

Not that many ! haha

about 64 dash 8 aircraft

I just realised what's different, what i am trying to get is an amount of a particular aircraft, not my whole fleet.

Sorry, i only just realised when i looked at the code

  • Moderators
Posted

I just realised what's different, what i am trying to get is an amount of a particular aircraft, not my whole fleet.

Sorry, i only just realised when i looked at the code

Okay I got it!

this goes to your .tpl anywhere in the table:

<tr>
	  <td align="center">DH8:</td>
	  <td align="center"><?php echo OperationsData::getAircraftByName(DH8);?></td>
</tr> 

Now change this in your OperationsData.class.php :

public static function getAircraftByName($name)
{
	$name = DB::escape(strtoupper($name));

	$sql = 'SELECT * 
			FROM ' . TABLE_PREFIX .'aircraft 
			WHERE UPPER(`name`)=\''.$name.'\'';

	return DB::get_row($sql);
}

To this:

public static function getAircraftByName($icao)
{
	$query = "SELECT * 
			FROM " . TABLE_PREFIX ."aircraft 
			WHERE icao ='".$icao."'";

	$results = DB::get_results($query);
	return DB::num_rows($results);
}

Remember to put aircraft icao (A322) instead of aircraft name (A320-200) in the .tpl wink.gif

  • Like 2
Posted

Okay I got it!

this goes to your .tpl anywhere in the table:

<tr>
	  <td align="center">DH8:</td>
	  <td align="center"><?php echo OperationsData::getAircraftByName(DH8);?></td>
</tr> 

Now change this in your OperationsData.class.php :

public static function getAircraftByName($name)
{
	$name = DB::escape(strtoupper($name));

	$sql = 'SELECT * 
			FROM ' . TABLE_PREFIX .'aircraft 
			WHERE UPPER(`name`)=\''.$name.'\'';

	return DB::get_row($sql);
}

To this:

public static function getAircraftByName($icao)
{
	$query = "SELECT * 
			FROM " . TABLE_PREFIX ."aircraft 
			WHERE icao ='".$icao."'";

	$results = DB::get_results($query);
	return DB::num_rows($results);
}

Remember to put aircraft icao (A322) instead of aircraft name (A320-200) in the .tpl wink.gif

Works great now, ill give you rep for all your hard work

Thankyou very much :)

Tylor

  • Moderators
Posted

Works great now, ill give you rep for all your hard work

Thankyou very much :)

Tylor

Actually! It wasn't that hard but I had to sleep since it was 2 in the morning. lol but thanks glad it worked for you. wink.gif

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