';
$tblHtml = $tblHtml . '
Bus no. | Direction | Distance from you | ETA |
';
$bUp = true;
$bDn = true;
$sqlstatus = 'CALL GetNearBus("' . $stopnameid . '")';
// echo $sqlstatus;
foreach ($conn2->query($sqlstatus) as $rowstat) {
$bno = $rowstat['busno'];
$di = $rowstat['distance'];
$tm = round($di / 1000 * 2); // Assuming speed of 30 km/hr
$dir = $rowstat['direction'];
if($dir == 'u' && $bUp) {
$tblHtml = $tblHtml . '' . $bno . ' | U | '
. $di . ' m | ' . $tm . ' min |
';
// echo '
u ' . $tblHtml;
$bUp = false;
}
else if($dir == 'd' && $bDn) {
$tblHtml = $tblHtml . '' . $bno . ' | D | '
. $di . ' m | ' . $tm . ' min |
';
// echo '
d ' . $tblHtml;
$bDn = false;
}
if(!$bUp && !$bDn)
break;
}
}
$tblHtml = $tblHtml . '';
echo $tblHtml;
/*** close the database connection ***/
$conn = null;
?>