Hello, I'm trying to do something like a game. This is something that a user buys, for example, a smartphone, laptop or computer and generates a profit. This shopping form is on a user page so you must sign in.
In the database, the user name, product that has purchased (smartphone, laptot or computer) and profit are recorded.
I would like to ensure that the purchased product is directly attributed to the same line as the user name of the person who is currently logged in (see picture below - in the database with 2 purchased smartphones attached to Marty).
This also raises the question of whether all users registered on the web should go directly to this database. (my database in second image)
When the user buys two other smartphones, for example, they enter 2 when they buy a total of 4, and another question is how to add this new value to the old one.
Each product also generates a certain profit, for which column 5 is used. E.g. 1 spartphone earns 1.66 / 30 days (0.055 / day) when the user has 4 smartphones, he earns 0.22 / day and this number should be credited once a day to the total profit.
The formula would look like this: the number of smartphones * 0.055 -> add to profit.
With ideas how to do it, I'm in the end and I wonder if it's going to be like this anyway. Anyway, I'm open to any of your suggestions or ideas.