I understand that I need a portfolio for each user, to contain their stocks and info, but how do I give each user a portfolio in the phpliteadmin? I know how to make one table, but I would need one "nested" or something inside the user DB or something like that? I'm just not sure where to put it, thanks
No, a single portfolio table is all you need. The secret is to have the correct columns and, more importantly, the correct unique index or key.
The table needs the following columns: userid, stock, quantity. You can add more columns, if they serve a useful purpose. Now, the magic sauce. There needs to be a unique key or index on the combination of the two columns userid and stock. This guarantees that there is only one row for the combination, for example, user23 and AAPL, but will still allow another entry for user23 and GOOG. When the number of shares of a certain stock for a certain user is increased or decreased, the row is updated, instead of adding a new row. Sell all of the shares? Delete the row.
"But how do I put all users in the same table?" you might ask? Well, when you want a single user's portfolio, you just need to select all rows where the userid matches the one you want.
It's really not that hard to do. ;-)
If this answers your question, please click on the check mark to accept. Let's keep up on forum maintenance. ;-)