Jump to content

Shedule Brief - Display local charts


Recommended Posts

Posted

No charts are displayed for any airports in the schdule briefing, so I modified the code to display charts found in the database.

If no charts are found it will display the default link for airnav.com plus the message "No local charts found, try - [airnavlink]".

You can see it here: http://www.flybritair.com/index.php/schedules/brief/1

You have to edit schedule_briefing.tpl

Replace:

<table width="98%" align="center">

<tr style="background-color: #333; color: #FFF;">
	<td>Charts for <?php echo $schedule->depicao?></td>
	<td>Charts for <?php echo $schedule->arricao?></td>
</tr>
<tr align="center">
	<td width="50%" valign="top">
		<a href="http://www.airnav.com/airport/<?php echo $schedule->depicao?>#ifr" target="_blank">
		<img border="0" src="http://flightaware.com/resources/airport/<?php echo $schedule->depicao?>/APD/AIRPORT+DIAGRAM/png"
			width="387px" height="594px" alt="No chart available" /></a>
	</td>
	<td width="50%" valign="top">
		<a href="http://www.airnav.com/airport/<?php echo $schedule->arricao?>#ifr" target="_blank">
		<img border="0" src="http://flightaware.com/resources/airport/<?php echo $schedule->arricao?>/APD/AIRPORT+DIAGRAM/png" 
			width="387px" height="594px" alt="No chart available" /></a>
	</td>

</tr>
</table>

With:

<table width="98%" align="center">

<tr style="background-color: #333; color: #FFF;">
	<td>Charts for <?php echo $schedule->depicao?></td>
	<td>Charts for <?php echo $schedule->arricao?></td>
</tr>
<tr align="center">
	<td width="50%" valign="top">
<?php
//Check local charts
$query_charts_dep = mysql_query("SELECT * FROM charts WHERE icao='".$schedule->depicao."'");

if (mysql_num_rows($query_charts_dep) == 0)
{
echo 'No local charts found, try - <a href="http://www.airnav.com/airport/'.$schedule->depicao.'#ifr" target="_blank">here</a>.';
}
while ($charts_results = mysql_fetch_assoc($query_charts_dep))
{
echo '<a href="'.$charts_results['link'].'">'.$charts_results['name'].'</a><br />';
}
?>

	</td>
	<td width="50%" valign="top">
<?php
//Check local charts
$query_charts_arr = mysql_query("SELECT * FROM charts WHERE icao='".$schedule->arricao."'");

if (mysql_num_rows($query_charts_arr) == 0)
{
echo 'No local charts found, try - <a href="http://www.airnav.com/airport/'.$schedule->arricao.'#ifr" target="_blank">here</a>.';
}
while ($charts_results = mysql_fetch_assoc($query_charts_arr))
{
echo '<a href="'.$charts_results['link'].'">'.$charts_results['name'].'</a><br />';
}
?>
	</td>

</tr>
</table>

  • 1 month later...
Posted

Not working for me:

Warning: mysql_query() [function.mysql-query]: Access denied for user 'freshje1'@'localhost' (using password: NO) in /home/freshje1/public_html/lib/skins/premiumseries/schedule_briefing.tpl on line 124

Warning: mysql_query() [function.mysql-query]: A link to the server could not be established in /home/freshje1/public_html/lib/skins/premiumseries/schedule_briefing.tpl on line 124

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/freshje1/public_html/lib/skins/premiumseries/schedule_briefing.tpl on line 126
No charts found!
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/freshje1/public_html/lib/skins/premiumseries/schedule_briefing.tpl on line 130

Need a password by the looks of it.

Posted

OK got rid of the login error through the mysql connect script, but I'm still left with the following:

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource in /home/freshje1/public_html/lib/skins/premiumseries/schedule_briefing.tpl on line 146
No charts found!
Warning: mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource in /home/freshje1/public_html/lib/skins/premiumseries/schedule_briefing.tpl on line 150

The code:

<?php

$con = mysql_connect("localhost","freshje1","*******");
if (!$con)
 {
 die('Could not connect: ' . mysql_error());
 }
//Check local charts
$query_charts_dep = mysql_query("SELECT * FROM charts WHERE icao='".$schedule->depicao."'");

if (mysql_num_rows($query_charts_dep) == 0)
{
       echo 'No charts found!';
}
while ($charts_results = mysql_fetch_assoc($query_charts_dep))
{
       echo '<a href="'.$charts_results['link'].'">'.$charts_results['name'].'</a><br>';
}
mysql_close($con);
?>

Posted

Fix:

<?php

$con = mysql_connect("localhost","username","password");
if (!$con)
 {
 die('Could not connect: ' . mysql_error());
 }
mysql_select_db( 'database_name' ); // usually username_phpvms
//Check local charts
$query_charts_dep = mysql_query("SELECT * FROM charts WHERE icao='".$schedule->depicao."'", $con);

if (mysql_num_rows($query_charts_dep) == 0)
{
       echo 'No charts found!';
}
while ($charts_results = mysql_fetch_assoc($query_charts_dep))
{
       echo '<a href="'.$charts_results['link'].'">'.$charts_results['name'].'</a><br>';
}
mysql_close($con);
?>

<?php

$con = mysql_connect("localhost","username","password");
if (!$con)
 {
 die('Could not connect: ' . mysql_error());
 }
mysql_select_db( 'database_name' ); // usually username_phpvms
//Check local charts
$query_charts_arr = mysql_query("SELECT * FROM charts WHERE icao='".$schedule->arricao."'", $con);

if (mysql_num_rows($query_charts_arr) == 0)
{
       echo 'No charts found!';
}
while ($charts_results = mysql_fetch_assoc($query_charts_arr))
{
       echo '<a href="'.$charts_results['link'].'">'.$charts_results['name'].'</a><br>';
}
mysql_close($con);
?>

  • 8 months later...
Posted

I added Kyle Vansers Airport_Charts_V1.1 yesterday and uploaded all my chart links this morning. This gives you one great addon for your website but the best news is...it merges with Will's Schedule Brief-Display local charts I added the replacement text into the schedule_briefing.tpl in the core templates and it supplies the link from my charts db in mysql which was created from Kyle's addon. This is just too cool. Thanks to both of you guys for some great addons.

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