Hello experts,
I need help. Please take a look at this code:
PHP Code:
$user_td = $db->fetch_array($result);
$result = $db->query("insert into ts_users(total_score) select sum(score) from ts_game_sessions where user_id = $user_id;");
This code is summing the all values of column "score" from tabel ts_game_sessions for "user_id". And then inserting sum of scores in column "total_score" of table ts_users.
Now the problem is, while inserting the summed value, it is creating a new user in ts_users and inserting summed value in "total_score" and autofilling new user details as NULL, NULL, NULL, NULL.
I want to insert summed value in "total_score" of existing user. How to do that?