<?php /* * This query out of all queries, is a nice one, since when signing in or signing up we set the * amount of available funds in the session, all we got to do is grab it. */ // SHOULD DO A CHECK TO MAKE SURE SESSION IS SET BEFORE WE ACTUALLY JUST USE THIS // Calling a model.php function echo get_clients_available_funds();
function check_how_much_the_stock_costs($passed_symbol, $passed_quantity) { $theStock = retrieve_yahoo_stock($passed_symbol); // We got a valid stock if ($theStock['symbol'] != "Not Value") { // tack on 20 for the trading cost $costOfStock = (double) ($theStock['price'] + 20) * (int) $passed_quantity; // check out if we can even purchase this $available_funds = (double) json_decode(get_clients_available_funds(), true)['available_funds']; // Dont have enough if ($costOfStock > $available_funds) { echo "Sorry you don't have enough to purchase this stock!"; } else { complete_the_trade($passed_quantity, $costOfStock, $theStock, $available_funds); } } else { echo "Not a valid stock that came back"; } }