Hi and thanks for taking the time to read this post
I have a customer database and have been trying to add a loyalty points system so that total of order x value = total loyalty points
I have it working so that when an order is received it updates the table_loyalty with the points and that is working fine
$points = $row["price"] * 1000;
$insert = mysql_db_query($db, "INSERT into table_loyalty (username, orderno, points) VALUES ('$username', '$this_orderno', '$points')", $connection);
check_mysql($insert);
However, what I would ideally like to be able to do but can't seem to get it to work (tried a few different ways) is to have a running total so that each additional order builds up the $points rather than add a separate record
I'm no coder which I'm sure is obvious but would appreciate any help.
I have tried this but didn't work:
$points = $row["points"];
$newpoints = $row["price"] * 1000;
$update = mysql_db_query($db, "update table_loyalty set points='$points'+'$newpoints' WHERE username='$username'", $connection);
check_mysql($update);
} else {
$insert = mysql_db_query($db, "INSERT into table_loyalty (username, orderno, points) VALUES ('$username', '$this_orderno', '$newpoints')", $connection);
check_mysql($insert);