Everything is working file but the cash is not updating. I think its due to typecasting. The value for shares is an integer and price is a float-point integer but I'm confused as to how to cast them.
Code:
// deletes the user's stock own and update the cash balance.
$stock = lookup($_POST["stocks"]);
// get how much a person own ( cash value of stock )
if ( $stock !== false )
{
$shares = query("SELECT shares FROM stocks WHERE id = ?",$_SESSION["id"] ) ;
$stockvalue = number_format($shares["shares"],2,'.','')
* number_format($stock["price"], 2, '.', '') ;
//update the current cash and delete the stocks
query("DELETE FROM stocks WHERE id = ?",$_SESSION["id"] );
query("UPDATE users SET cash = cash + ? WHERE id = ?",$stockvalue, $_SESSION["id"]);
redirect("index.php");
}