Save multiple data with a single identifier in mysql and php

Asked

Viewed 42 times

-1

I’m making a screen to show the discounts in opencart admin, by sub store, I can already save in a table for testing, the biggest problem is: How should be done properly in this case to be saved in BD?

  • Need to show as table with delete option, in each row will have some data like, Store, applied percentage, start and end date and delete.
  • The data comes from several tables.

For example: includes a discount on ten products for sub store "A" and on another 7 for sub store "B", originally, both discounts are saved in a single table, but I intend to create another table referencing which products is from which sub store, and show on screen and be able to delete all with one button.

Note: I do so, because the table with the data of the discounts does not have anything to refer to which discount and which sub store, everything gets mixed, and I did not want to touch this table, but create another.

Demo screen: No quadrado vermelho é onde vão aparecer os descontos In the red square is where the discounts will appear

I hope I was clear :)

1 answer

1

Loajas modeling (already existing)

store(id, name, [...])

Product modeling (already existing)

product(id, code, description, [...])

Discount Modeling (Which I would do)

store(id, loja_id, product, dataInicio, dataFim, per100)

Primary kry (id)

Foreign key (loja_id) for store id

Foreign key (product id) for product id

Unique index (product, date)

I would make a view that brings together the data of products, stores and discount and prepare a layout that has as main link to deletion, the discount id.

After the created view, you send html the qye is more convenient only the id that would be required, because it would delete the discounts.

  • Thank you for your reply. I thought the following thing, create a table (oc3_product_special_discounts), why I will have to show the percentage of the discount on the addition screen, this data is not stored in any table. understands?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.