Jump to content

Flight Board replace image with text Need help


IrfanKhan

Recommended Posts

Hello actually i am trying to create flight board on which instead of all the text we can replace images of alphabets by using str_replace command.

i do not have idea as from where to start i wanted to build a simple flight board on which instead of text for example getting flight number

<?php echo $flight->flightnum?>

instead it shows just text Dubai International Airport the text should replace the each alphabet with each alphabet image and full airport name will be display as image not as text so i just have idea we need to put replace command to achieve the final result i will appreciate if someone would help me in building this flight board i will be more then happy to share with all the forum members the final code.

something like this just an example

function FlightNumReplace ($ReplaceText)
{
$Numbers=array(
 '1' => "<img src='/images/date/1.gif' />",
 '2' => "<img src='/images/date/2.gif' />",
 '3' => "<img src='/images/date/3.gif' />",
 '4' => "<img src='/images/date/4.gif' />",
 '5' => "<img src='/images/date/5.gif' />",
 '6' => "<img src='/images/date/6.gif' />",
 '7' => "<img src='/images/date/7.gif' />",
 '8' => "<img src='/images/date/8.gif' />",
 '9' => "<img src='/images/date/9.gif' />",
 '0' => "<img src='/images/date/0.gif' />"
);
$FlightNum=str_replace(array_keys($Numbers), array_values($Numbers), $ReplaceText);
return $FlightNum;
}

Thanks

Irfan Khan

  • Like 1
Link to comment
Share on other sites

Thanks for your response Simpilot really appreciate your and support towards phpvms community.

Actually i am not getting the code working i tried putting it in frontpage_main.tpl not understanding the structure fully as how the code will work where should i put it exactly and output will come on flightboard and also the above code will only replace FlightNum how we can create a code which will replace all the text at once for all the flight board output text? i request you to help me combining the code with flight board code so it will work properly i tried the below code.

<h3 style="text-align: left;">Flight Status Board</h3>
<left>
<div id="fboard" style="border:solid 1px #060">
<table class="imagetable2" width="100%" cellpadding="0" cellspacing="0">
 <thead>
	 <tr style="font-size:11px;">
		 <th width="6%" align="center" style="background-color: #0B3861; width: 3.5%;">Airline</th>
		 <th width="10%" align="left" style="background-color: #0B3861; "><font color="#ffc600">Flight</font></th>
		 <th width="25%" align="left" style="background-color: #0B3861; width: 33%;"><font color="#ffc600">Departing</font></th>
		 <th width="25%" align="left" style="background-color: #0B3861; width: 33%;"><font color="#ffc600">Arriving</font></th>
<th width="5%" align="center" style="background-color: #0B3861; "><font color="#ffc600">Pilot</font></th>
		 <th width="8%" align="center" style="background-color: #0B3861; "><font color="#ffc600">Aircraft</font></th>
		 <th width="12%" align="center" style="background-color: #0B3861; "><font color="#ffc600">Status</font></th>
		 <th width="5%" align="center" style="background-color: #0B3861; "><font color="#ffc600">ETE</font></th>
		 <th align="center" style="background-color: #0B3861; "> </th>
	 </tr>
 </thead>
 <tbody>
 <?php
	 $flights = ACARSData::GetACARSData();
	 if ($flights OR $fsfk > 0) {
		 if($flights) {
		 foreach($flights as $flight) {
				 $pid = $flight->pilotid + 100;
 function FlightNumReplace ($ReplaceText)
{
$Numbers=array(
'1' => "<img src='/images/date/1.gif' />",
'2' => "<img src='/images/date/2.gif' />",
'3' => "<img src='/images/date/3.gif' />",
'4' => "<img src='/images/date/4.gif' />",
'5' => "<img src='/images/date/5.gif' />",
'6' => "<img src='/images/date/6.gif' />",
'7' => "<img src='/images/date/7.gif' />",
'8' => "<img src='/images/date/8.gif' />",
'9' => "<img src='/images/date/9.gif' />",
'0' => "<img src='/images/date/0.gif' />"
);
$FlightNum=str_replace(array_keys($Numbers), array_values($Numbers), $ReplaceText);
return $FlightNum;
}?>
		 <tr style="height:12px; font-size:10px; font-weight:normal; ">
			 <td align="left" valign="middle" style="background-color: #363433; padding-right: 0px; border-bottom-style:solid; border-bottom-width:1px; border-bottom-color:#363433"><?php
$str = "$flight->flightnum";
$find="PIA";
$position = strpos($str,$find);
if ($position === false){
echo ""; } else { echo "<img style='padding-left:3px;' width='80px'; height='20px'' src=''>"; }?></td>
			 <td align="left" valign="middle" style="background-color: #363433; border-bottom-style:solid; border-bottom-width:1px; border-bottom-color:#363433"><font face="digi"font size=2 color="#eecb04"><?php echo $flight->flightnum?></font></td>
			 <td align="left" valign="middle" style="background-color: #363433; padding-right: 5px; border-bottom-style:solid; border-bottom-width:1px; border-bottom-color:#363433"><font face="digi"font size=2 color="#ffc600"> <?php echo $flight->depapt?></font></td>
			 <td align="left" valign="middle" style="background-color: #363433; padding-right: 5px; border-bottom-style:solid; border-bottom-width:1px; border-bottom-color:#363433"><font face="digi"font size=2 color="#ffc600"> <?php echo $flight->arrapt?></font></td><td align="left" valign="middle" style="background-color: #363433; padding-right: 0px; border-bottom-style:solid; border-bottom-width:1px; border-bottom-color:#363433"><font face="digi"font size=2 color="#ffc600"> <?php echo $flight->pilotname?> </font></td>
			 <td align="left" valign="middle" style="background-color: #363433; padding-right: 0px; border-bottom-style:solid; border-bottom-width:1px; border-bottom-color:#363433"><font face="digi" font size=2 color="#ffc600"> <?php echo $flight->aircraftname?> </font></td>
</tr>
<?php
}
}{
mysql_select_db('TEST');
$dep = mysql_fetch_assoc(mysql_query("SELECT name FROM phpvms_airports WHERE icao = '$row[OriginAirport]'"));
$arr = mysql_fetch_assoc(mysql_query("SELECT name FROM phpvms_airports WHERE icao = '$row[DestinationAirport]'"));
$row['OriginAirport'];
?>
<?php
}
} else { ?>
<tr><td align="center" colspan="10" style="padding: 5px; font-size: 13px; font-weight: bold; color: #ffc600; background-color: #363433;">No flights in Progress!</td></tr>
<?php
}
?>
</tbody>
</table>
</div>

thanking you once again

Irfan Khan

Link to comment
Share on other sites

  • Administrators

I am not exactly sure what you are trying to accomplish with the code you have posted. I think that a couple of things might help you though.

1 - Get rid of the function in your template.

2 - create your variable array ($Numbers) outside, but before the foreach loop, or even better in your controller and then pass the variable to the template.

3 - just put the base code in your table line where you need it, something like:

<td><?php echo strtr($flight->flightnum, $Numbers); ?></td>

4 - another thing that may be causing you issue is that the $flight-flightnum possibly has some alpha characters at the start, i am not sure what it holds in that template.

Just my opinion but you should also get those database calls out of your template and into a model somewhere.

Link to comment
Share on other sites

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