I have a MySQL database. This consists of various tables, including 'members' and 'stocks'.

I am creating a 'stock trading game' and want to deduct the amount a stock costs, from the balance a user currently has. 

I have the column 'price' within the stocks table and
the column 'balance' within the members table.

When a button is clicked I want the price of a stock to be subtracted from the balance of a member.

If I'm honest, I have no idea on how to do this, but as an attempt here is my code that I have tried, but actually does nothing:

```
if (isset($_POST['user']))
{
    $userselection = sanitizeString($_POST['userselection']);

    if ($userselection == "")
        $error = "Not all fields were entered<br /><br />";
    else
    {
            $stockprice = queryMysql("SELECT price FROM stocks WHERE name='$userselection'");
            $newbalance = ($balance - $stockprice);
            queryMysql("INSERT INTO members VALUES('', '', '', '', '', '', '$newbalance',  )");
            die("<h4>You just bought $userselection</h4><br /><br />");

    }
}

```

schema:
![enter image description here](https://i.stack.imgur.com/YK1mm.png)

```
<?php 
include_once 'functions.php';

createTable('members',
            'id INT(50) NOT NULL AUTO_INCREMENT,
            firstname VARCHAR(100),
            surname varchar(100),
            user varchar(30),
            pass varchar(30),
            email varchar(100),
            balance float(12),
            PRIMARY KEY (id)');

createTable('stocks', 
            'id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
            name VARCHAR(16),
            price float(16)');

createTable('profiles',
            'user VARCHAR(16),
            text VARCHAR(4096)');

?>

```