This page helps me keep track of the ports visited by ship. Although "visited"
sometimes only meant touching the pier or seeing the city from afar.
Calls:
2220
Ports:
832
Countries (political), excl. Antarctica:
104
Countries incl. Outlaying Territorries:
156
Average Port Re-Visiting Rate:
2.67x
Call at anchor Cruising Expedition
//Read Distinct Country
$sql_rc = "SELECT DISTINCT country FROM sea_itinerary ORDER BY country ASC";
$res_rc = mysqli_query($db, $sql_rc) or die("SQL Error: [read countries]");
while($line_rc = mysqli_fetch_array($res_rc)) {
//Lookup Flag
$sql_rf = "SELECT * FROM sea_flag WHERE country='".$line_rc["country"]."'";
$res_rf = mysqli_query($db, $sql_rf) or die("SQL Error: [read flag]");
if($line_rf = mysqli_fetch_array($res_rf)) {
//Flag Found
$flag_path = "flags/".$line_rf["filename"];
}
else {
$flag_path = "flags/none.gif";
}
//Read Numbers of Calls for this Country
$sql_rcc = "SELECT * FROM sea_itinerary WHERE country='".$line_rc["country"]."'";
$res_rcc = mysqli_query($db, $sql_rcc) or die("SQL Error: [read country calls]");
$number_of_calls_country = mysqli_num_rows($res_rcc);
print "
";
//Read Ports for this Country (without state)
print "
";
$sql_rp = "SELECT DISTINCT port FROM sea_itinerary WHERE country='".$line_rc["country"]."' AND state='' ORDER BY port ASC";
$res_rp = mysqli_query($db, $sql_rp) or die("SQL Error: [read ports]");
while($line_rp = mysqli_fetch_array($res_rp)) {
//Read Numbers of Calls for this Port
$sql_rpc = "SELECT * FROM sea_itinerary si INNER JOIN sea_contract sc ON si.contract_no=sc.id WHERE si.country='".$line_rc["country"]."' AND si.port='".$line_rp["port"]."' ORDER BY si.arrival";
//print $sql_rpc;
$res_rpc = mysqli_query($db, $sql_rpc) or die("SQL Error: [read port calls]");
$number_of_calls = mysqli_num_rows($res_rpc);
$details = "
";
$anchor_call = false;
$anchor_port = false; //will be set true if at least one call to this port was at anchor
$cruising_call = false;
$cruising_port = false; //will be set true if at least one call to this port was cruising
$expedition_call = false;
$expedition_port = false; //will be set true if at least one call to this port was expedition
while($line_rpc = mysqli_fetch_array($res_rpc)) {
if($line_rpc["type"] == "A") {
$anchor_call = true;
$anchor_port = true;
}
if($line_rpc["type"] == "C") {
$cruising_call = true;
$cruising_port = true;
}
if($line_rpc["type"] == "E") {
$expedition_call = true;
$expedition_port = true;
}
$now = strtotime(date('Y-m-d'));
$past = strtotime($line_rpc["arrival"]);
$seconds = round($now - $past);
$days = round($seconds/60/60/24);
$years = floor($days/365);
$remaining_days = $days - ($years*365);
switch($years) {
case "0": $y_text = ""; break;
case "1": $y_text = "1 year, "; break;
default: $y_text = $years." years, ";
}
switch($remaining_days) {
case "1": $d_text = "1 day "; break;
default: $d_text = $remaining_days." days ";
}
$details .= getDateFromTimeStamp($line_rpc["arrival"])." ".$line_rpc["vessel"]." - ".$y_text.$d_text." ago";
if($anchor_call) {
$details .= " ";
}
if($cruising_call) {
$details .= " ";
}
if($expedition_call) {
$details .= " ";
}
$details .= " ";
$anchor_call = false; //reset for next call
$cruising_call = false; //reset for next call
$expedition_call = false; //reset for next call
}
$details .= "
";
$anchor_port = false; //reset for next port
}
print "
\n";
//Read Ports for this Country (with state)
$sql_rs = "SELECT DISTINCT state FROM sea_itinerary WHERE country='".$line_rc["country"]."' AND state!='' ORDER BY state ASC";
$res_rs = mysqli_query($db, $sql_rs) or die("SQL Error: [read states]");
while($line_rs = mysqli_fetch_array($res_rs)) {
//Make State Header
//Lookup State Flag
$sql_rf = "SELECT * FROM sea_flag WHERE country='".$line_rs["state"]."'";
$res_rf = mysqli_query($db, $sql_rf) or die("SQL Error: [read flag]");
if($line_rf = mysqli_fetch_array($res_rf)) {
//Flag Found
$flag_path = "flags/".$line_rf["filename"];
}
else {
$flag_path = "flags/none.gif";
}
//Read Numbers of Calls for this State
$sql_rsc = "SELECT * FROM sea_itinerary WHERE state='".$line_rs["state"]."'";
$res_rsc = mysqli_query($db, $sql_rsc) or die("SQL Error: [read state calls]");
$number_of_calls_state = mysqli_num_rows($res_rsc);
print " ";
print "
";
$sql_rps = "SELECT DISTINCT port FROM sea_itinerary WHERE country='".$line_rc["country"]."' AND state='".$line_rs["state"]."' ORDER BY port ASC";
$res_rps = mysqli_query($db, $sql_rps) or die("SQL Error: [read port in state]");
while($line_rps = mysqli_fetch_array($res_rps)) {
//Read Numbers of Calls for this Port
$sql_rpc = "SELECT * FROM sea_itinerary si INNER JOIN sea_contract sc ON si.contract_no=sc.id WHERE si.country='".$line_rc["country"]."' AND si.port='".$line_rps["port"]."' ORDER BY si.arrival";
$res_rpc = mysqli_query($db, $sql_rpc) or die("SQL Error: [read port calls]");
$number_of_calls = mysqli_num_rows($res_rpc);
$details = "
";
$anchor_call = false;
$anchor_port = false; //will be set true if at least one call to this port was at anchor
$cruising_call = false;
$cruising_port = false; //will be set true if at least one call to this port was cruising
$expedition_call = false;
$expedition_port = false; //will be set true if at least one call to this port was expedition
while($line_rpc = mysqli_fetch_array($res_rpc)) {
if($line_rpc["type"] == "A") {
$anchor_call = true;
$anchor_port = true;
}
if($line_rpc["type"] == "C") {
$cruising_call = true;
$cruising_port = true;
}
if($line_rpc["type"] == "E") {
$expedition_call = true;
$expedition_port = true;
}
$now = strtotime(date('Y-m-d'));
$past = strtotime($line_rpc["arrival"]);
$seconds = round($now - $past);
$days = round($seconds/60/60/24);
$years = floor($days/365);
$remaining_days = $days - ($years*365);
switch($years) {
case "0": $y_text = ""; break;
case "1": $y_text = "1 year, "; break;
default: $y_text = $years." years, ";
}
switch($remaining_days) {
case "1": $d_text = "1 day "; break;
default: $d_text = $remaining_days." days ";
}
$details .= getDateFromTimeStamp($line_rpc["arrival"])." ".$line_rpc["vessel"]." - ".$y_text.$d_text." ago";
if($anchor_call) {
$details .= " ";
}
if($cruising_call) {
$details .= " ";
}
if($expedition_call) {
$details .= " ";
}
$details .= " ";
$anchor_call = false; //reset for next call
$cruising_call = false; //reset for next call
$expedition_call = false; //reset for next call
}
$details .= "