American Markets
"; //Day Date Month Year [Time (24-hour system)] print(date("l d F Y")); print(" ["); print(date("H")); print(date("i")); print("]

"); //include fn.php for use below $dir='.'; include($dir.'/fn.php'); //call retrieving function in fn.php for the major indices //^DJI, ^IXIC, and ^GSPC are Yahoo! Finance designations for the indices //retrieve obtains current value, change in points, and change in percent //retrieve also continues printing in table started below echo ""; $markets = '^DJI'; $quotes = retrieve($markets); echo ""; $markets = '^IXIC'; $quotes = retrieve($markets); echo ""; $markets = '^GSPC'; $quotes = retrieve($markets); echo "
"; echo "Dow Jones Industrial
NASDAQ Composite
Standard & Poor's 500

"; echo "

Portfolio of $ViewMethod
"; echo "————————"; echo "————————"; echo "————————"; echo "————————"; echo "————————"; echo "————————"; echo "————————"; echo "————————

"; $link = mysql_connect("magnesium.tjhsst.edu", "jhess", "939525"); mysql_select_db("jhess", $link); if ($ViewMethod=="Mr. Latimer") $query = "select * from latimer"; if ($ViewMethod=="Yosemite Sam") $query = "select * from sam"; $result = mysql_query($query, $link); $num_rows = mysql_num_rows($result); echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
StockQuantityPriceChangeInformationWorth
"; echo "————————"; echo "————————"; echo "————————"; echo "————————"; echo "————————"; echo "————————"; echo "————————"; echo "————————
"; echo ""; for ($c = 0; $c < $num_rows; $c++) { $row = mysql_fetch_array($result); $stock = $row["stock"]; $qty = $row["qty"]; //obtain a page containing data regarding $symbols $url = "http://finance.yahoo.com/q?s=$stock&d=t"; if (!($fp = fopen($url, "r"))) { echo "Unable to open page."; exit; } //if opening is successful, read 100000 bytes from opened page $contents = fread($fp, 100000); //close page fclose($fp); if (preg_match("/([0-9]+\.[0-9]+<\/b>)/", $contents, $quote)) $price = $quote[1]; if (preg_match("/(Change
\-[0-9]+\.[0-9]+)/", $contents, $chg)) {$chg[1] = substr($chg[1], 29); $change = $chg[1];} if (preg_match("/(\+[0-9]+\.[0-9]+)/", $contents, $chg)) $change = $chg[1]; if (preg_match("/(0\.00)/", $contents, $chg)) { $chg[1] = substr($chg[1], 25); $change = $chg[1]; } if (preg_match("/(\-[0-9]+\.[0-9]+\%)/", $contents, $chgp)) $changep = $chgp[1]; if (preg_match("/(\+[0-9]+\.[0-9]+\%)/", $contents, $chgp)) $changep = $chgp[1]; $worth = substr_replace($price, '', 5, 1); echo "
"; echo ""; echo ""; if (preg_match("/(\+)/", $chgp[1], $extra)) { echo ""; } else { echo ""; } echo ""; if (strlen($price)==12) echo ""; else echo ""; echo ""; } echo "
$stock$qty$price"; echo "$change
$changep
"; echo "$change
$changep
"; data($stock); echo"$worth.00N/A
"; echo "————————"; echo "————————"; echo "————————"; echo "————————"; echo "————————"; echo "————————"; echo "————————"; echo "————————

"; ?>
STOCK DATA RETRIEVED FROM YAHOO! FINANCE