hi, sorry for the late reply, it was actually around 2 am in my part of the world yesterday night, or should i say today morning... this is my code for index.php
Code:
<?php
// configuration
require("../includes/config.php");
//defining positions
$cash = query ("SELECT cash FROM users WHERE id = ?", $_SESSION["id"]);
$positions = [];
$rows = query ("SELECT symbol, shares FROM portfolio WHERE id = ?", $_SESSION["id"]);
foreach ($rows as $row)
{
$stock = lookup($row["symbol"]);
if ($stock !== false)
{
$positions[]= [
"name" => $stock["name"],
"price" => $stock["price"],
"shares" => $row["shares"],
"symbol" => $row["symbol"]
];
}
}
// render portfolio
render("portfolio.php", ["positions" => $positions, "title" => "Portfolio", "cash" => $cash]);
?>
and portfolio.php basically prints all the values in $positions in a table... may be this will interest you too,the following is my config.php file included on top...
Code:
<?php
// display errors, warnings, and notices
ini_set("display_errors", true);
error_reporting(E_ALL);
// requirements
require("constants.php");
require("functions.php");
// enable sessions
session_start();
// require authentication for most pages
if (!preg_match("{(?:login|logout|register)\.php$}", $_SERVER["PHP_SELF"]))
{
if (empty($_SESSION["id"]))
{
redirect("login.php");
}
}
?>
thank you so much, for everything... there are very few people out there who do what you've done, sharing knowledge and time...
Bookmarks