<?php
$hostName = "localhost";
header("Content-type: image/png");
/* CHANGE THESE LINES BELOW TO YOUR DETAILS */
$userName = "";
$password = "";
$dbName = "";
/* make connection to database */
mysql_connect($hostName, $userName, $password) or die("Unable to connect to host $hostName");
mysql_select_db($dbName) or die("Unable to select database $dbName");
$sql = "SELECT lat, lon, alt, gs, IATA, phase FROM positions WHERE last_update > DATE_SUB( NOW() , INTERVAL 15 MINUTE )";
$result = mysql_query( $sql );
$phase = ' phase ';
/* mysql error */
if (!$result) {
mysql_close();
die("Error - Database Connection.");
}
if (mysql_result($result) == 0) {
($im = ImageCreateFromPng("off.png"));
} elseif ($phase = 1) {
$im = (mysql_result($result,"phase") == 1 );
$im = ImageCreateFromPng("embarque.png");
// Boarding
} elseif ($phase = 2) {
$im = (mysql_result($result,"phase") == 2 );
$im = ImageCreateFromPng("taxidosgates.png");
// Taxi From Gate
} elseif ($phase = 3) {
$im = (mysql_result($result,"phase") == 3 );
$im = ImageCreateFromPng("decolando.png");
// Departing
} elseif ($phase = 4) {
$im = (mysql_result($result,"phase") == 4 );
$im = ImageCreateFromPng("subida.png");
// Climbing
} elseif (mysql_result($result,"phase") == 5 ) {
$im = (mysql_result($result,"phase") == 5 );
$im = ImageCreateFromPng("cruzeiro.png");
// Cruising
} elseif ($phase = 6) {
$im = (mysql_result($result,"phase") == 6 );
$im = ImageCreateFromPng("descida.png");
// Descending
} elseif ($phase = 7) {
$im = (mysql_result($result,"phase") == 7 );
$im = ImageCreateFromPng("landed.png");
// Landed
} elseif ($phase = 8) {
$im = (mysql_result($result,"phase") == 8 );
$im = ImageCreateFromPng("taxiparagates.png");
// Taxi To Gate
} elseif ($phase = 9) {
$im = (mysql_result($result,"phase") == 9 );
$im = ImageCreateFromPng("chegadagate.png");
// Arrived at Gate
} else {
$im = (mysql_result($result,"phase") == 0 );
$im = ImageCreateFromPng("off.png");
//montar erro aqui, tipo se não ler os acima coloca aqui imagem: online
}
//|ImageCreateFromPng("off.png");
//header("Content-type: image/png");
//$string = "Foo";
//$im = imagecreatefrompng("images/button1.png");
//$orange = imagecolorallocate($im, 220, 210, 60);
//$px = (imagesx($im) - 7.5 * strlen($string)) / 2;
//imagestring($im, 3, $px, 9, $string, $orange);
//
imagepng($im);
//
imagedestroy($im);
//
?> estou com esse codigo mas só aprece a imagem OFF mesmo quando o PHASE no BD ta 1 ou 2 etc...