Location: PHPKode > projects > Terra Nova > port.php
<?php

$require_login = true;
$gamescript = true;
$summaryscript = false;

include("common.php");

$porttype = $db->select("*","commodities","commodity_id='$sectorinfo[sector_portcontents]'",1);

//echo "PORTTYPE: $porttype[commodity_name]";

$portvar = "port_$porttype[commodity_name]_stock";

$initialstockamount = 100000000;

$multiplier = $initialstockamount / $sectorinfo[$portvar];
$price = $multiplier * $porttype[commodity_sellprice];

//echo "Price: $price<BR>Initial amount: $initialstockamount<BR>Multiplier: $multiplier<BR>Stock: $sectorinfo[port_Tech_stock]<BR>Baseamount: $porttype[commodity_baseamount]";

if($sectorinfo[port]=="N")
{
$page->Assign("content",newbox("Trading Port","Sorry, but there is no trading port in this sector, please click <a class=\"nav\" href=\"javascript:history.go(-1)\">here</a> to go back to where you were"));
$page->Display("template");
}
elseif($porttype[commodity_name]=="Special")
{
Header("Location:special.php");
}
elseif(!isset($action))
{

$page->Assign("sectorid",$sectorinfo[sector_id]);

$commodities = $db->select("*","commodities","commodity_name != 'special'",0);

$commodityhtml = "<TABLE BORDER=\"0\">";
$commodityhtml .= "<TR><TD CLASS=\"genericbox1_head\">Commodity</TD><TD CLASS=\"genericbox1_head\">Commodity Cost</TD><TD CLASS=\"genericbox1_head\">Purchase Amount</TD></TR>";

while($row = mysql_fetch_array($commodities))
{

$sellprice = $row[commodity_sellprice] / 2;
$commodityhtml .= "<TR><TD CLASS=\"genericbox1_body\">$row[commodity_name]</TD><TD CLASS=\"genericbox1_body\">$sellprice</TD><TD CLASS=\"genericbox1_body\"><INPUT type=\"text\" name=\"$row[commodity_name]_buyamount\" value=\"0\"></TD></TR>";

}

$commodityhtml .= "</TABLE>";

$item = $db->select("*","commodities","commodity_id='$sectorinfo[sector_portcontents]'",1);

$sellcommodityhtml = "<TR><TD CLASS=\"genericbox1_head\">Commodity</TD><TD CLASS=\"genericbox1_head\">Commodity Buy Price</TD><TD CLASS=\"genericbox1_head\">Sale Amount</TD></TR>";
$sellcommodityhtml .= "<TABLE BORDER=\"0\"><TR><TD CLASS=\"genericbox1_body\">$item[commodity_name]</TD><TD CLASS=\"genericbox1_body\">$item[commodity_sellprice]</TD><TD CLASS=\"genericbox1_body\"><INPUT type=\"text\" name=\"sellamount\" value=\"0\"></TD></TR></TABLE>";

$page->Assign("purchasecost",$price);

$page->Assign("purchaseitem",$item[commodity_name]);

$page->Assign("purchasecommoditieshtml",$commodityhtml);

$page->Assign("sellcommoditieshtml",$sellcommodityhtml);

$content = $page->FetchTemplate("TradingStation");

$page->Assign("content",newbox("Trading Station",$content));

$page->Display("template");

}

?>
Return current item: Terra Nova