";
for ($firstrunonline=$firstrun;$firstrunonline<=$lastrun;$firstrunonline=$firstrunonline+3)
{
if ($passeddirection=="SOUTH")
{
$sql = "SELECT * FROM stop where ".$tt_type." != 0 order by ".$tt_type." desc";
}
if ($passeddirection=="NORTH")
{
$sql = "SELECT * FROM stop where ".$tt_type." != 0 order by ".$tt_type."";
}
$result = $conn->query($sql);
if ($result->num_rows > 0)
{
// Allocation data here
echo "";
echo " | ";
for ($allocshow=$firstrunonline;$allocshow<$firstrunonline+3;$allocshow++)
{
$sqlal = "SELECT * FROM timetablebase where run =\"".$allocshow."\" and direction= \"".$passeddirection."\" and timetable=\"".$tt_type."\" and stop=\"PIER\"";
$resultal = $conn->query($sqlal);
$rowal = $resultal->fetch_assoc();
if ($rowal["allocation"] != "")
{
$sqlal2 = "SELECT * FROM timetableallocation where ttdate =\"".$date."\" and ttalloc= \"".$rowal["allocation"]."\"";
$resultal2 = $conn->query($sqlal2);
$rowal2 = $resultal2->fetch_assoc();
if ($rowal2["tttram"] != "")
{
$tramnumber="
(".$rowal2["tttram"].")";
}
else
{
$tramnumber="";
}
// Do links for allocation stuff
// echo"".$rowal["allocation"]."".$tramnumber." | ";
// No links in version below
echo"".$rowal["allocation"].$tramnumber." | ";
}
}
echo "
";
// Allocation done
while($row = $result->fetch_assoc())
{
$outbuffer="";
$doshowthis = 0;
// This links to stops
// echo "".$row["stopname"]." | ";
// This next one doesn't
if ($row["stop"]=="FLTW")
{
if ($passeddirection=="SOUTH")
{
$stopname=$row["stopname"]." Pharos St.";
}
else
{
$stopname=$row["stopname"]." Ferry";
}
}
else
{
$stopname=$row["stopname"];
}
$outbuffer = $outbuffer . "
".$stopname." | ";
// get next 3 runs
$tmpruncount=$firstrunonline;
$tmpruncount2=$firstrunonline+2;
$sql2 = "SELECT * FROM timetablebase where direction= \"".$passeddirection."\" and stop=\"".$row["stop"]."\" and run>=\"".$tmpruncount."\" and run<=\"".$tmpruncount2."\" and timetable=\"".$tt_type."\" ";
$result2 = $conn->query($sql2);
if ($result2->num_rows > 0)
{
while($row2 = $result2->fetch_assoc())
{
if ($row2["time"] == "23:59:00")
{
$outbuffer = $outbuffer . "--:-- | ";
}
else
{
$outbuffer = $outbuffer . "".substr($row2["time"], 0, 5)." | ";
$doshowthis=1;
}
}
}
$outbuffer = $outbuffer . "
";
if ($doshowthis==1)
{
echo $outbuffer;
}
}
// Via here
echo "";
echo " | ";
for ($viashow=$firstrunonline;$viashow<$firstrunonline+3;$viashow++)
{
$sqlvia = "SELECT * FROM timetablebase where run =\"".$viashow."\" and direction= \"".$passeddirection."\" and timetable=\"".$tt_type."\" and stop=\"VIA\"";
$resultvia = $conn->query($sqlvia);
$rowvia = $resultvia->fetch_assoc();
echo"".$rowvia["destination"]." | ";
if ($rowvia["destination"] == "TG")
{ $tg++;}
if ($rowvia["destination"] == "LB")
{ $lb++;}
}
echo "
";
// Via done
echo " |
";
}
}
echo "