I have created two tables in my database named : portfolio and user_data. portfolio has fields as: user_id, Symbol, Name, Shares, Price, Total, Datetime all of them "NOT UNIQUE" so as to let the user purchase more of same or other stock. Whereas, in user_data I have fields as: user_id, Symbol,Name, Shares, Price, Total all are "NOT UNIQUE". user_data stores the total shares and total price of all shares of a particular user for a particular stock so as to show the user updated data with total of all shares and price rather than showing the row by row purchase. As I execute my code if a user say Andi buys 2 shares of NFLX she gets a table showing 2 shares of NFLX. If Andi buys NFLX another 2 shares a table showing 0 shares of NFLX appears with Total of only 2 shares rather than 4. Here's my code for buy:

Any suggestions will be appreciated!


I was little bit confused over the algorithm for my code but now it's solved as I have finally realized that I have only choose between disc space and runtime for this issue.Code removed for academic honesty,thanks!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .