OK, to answer how I built the array:
$statistics_db_query = t('SELECT portfolio_transactions.uid, portfolio_transactions.symbol, portfolio_transactions.shares, portfolio_transactions.price AS originalprice, (
portfolio_transactions.shares * portfolio_transactions.shares
) + portfolio_transactions.commission AS cost, portfolio_transactions.transaction_date AS purchasedate, portfolio_transactions.type, portfolio_transactions.commission, portfolio_transactions.amount
FROM portfolio_transactions WHERE uid = !uid;', array('!uid' => $user->uid,));
$statistics_db_results = db_query($statistics_db_query);
$symbols = array();
$performancedata = array();
$headers = array();
$headers = _portfolio_needed_headers('block');
$quotes = array();
$quotes = _portfolio_fetch_quotes($symbols, $headers);
while ($statistics = db_fetch_object($statistics_db_results)) {
$symbols[] = $statistics->symbol;
$performancedata[][0] = $statistics->symbol;
$performancedata[][1] = $statistics->shares;
$performancedata[][2] = $statistics->originalprice;
$performancedata[][3] = ''; //Current Price
$performancedata[][4] = $statistics->commission;
$performancedata[][5] = $statistics->cost;
$performancedata[][6] = ''; //Current Value
$performancedata[][7] = ''; //Lost or Gain
$performancedata[][8] = $statistics->purchasedate;
$performancedata[][9] = $statistics->type;
$performancedata[][10] = $statistics->amount;
}
$quotes = array();
$quotes = _portfolio_fetch_quotes($symbols, $headers);
$i = 0;
foreach ($quotes as $quote) {
$performancedata[$i][3] = $quote[3];
$performancedata[$i][6] = ($quote[3]*$performancedata[$i][1]) + $performancedata[$i][4];
$performancedata[$i][7] = $performancedata[$i][6] - $performancedata[$i][5];
}
The db_query() function is a function from Drupal that runs the query against the database for me (and returns a handle) and the db_fetch_object() function gets the results (provided you supply the handle).
Let me know if I am doing something wrong here.
Thanks for your time.
Regards,
Christopher Koeber