I have a database with a transaction field, this displays products brought on my website. I am trying to develop an admin interface where i can see the products brought.
The string looks like this
37,2:27,1:5,3:94,10:49,15:
This basically means that the customer ordered product ID number 37 with the quantity of 2. Included in their transacvtion was product id 27 with qty 1 and so on.
product_id,ordered_quantity:nextproduct_id,next_orderedquantity.
In order to display this information I need to break this down. I have tried php explode but having some trouble. So we need to split the product on colon : and the qty and id by comma. The string can be one product or many.
Anyone got any suggestions?
You get a profuct id – quantity array.
This way of storing data is non-scalable and error-prone. Why not use a table with the following fields: userId, productId, quantity?