Generate PHP table with specific data for Mysql

Asked

Viewed 75 times

0

I have a table in a Mysql database, and I need to generate a table with PHP, but it is not a trivial table. My table has the following fields: codigo, item, preco and quantidade. I need to generate a table where for example I have the following data:

codigo = BC0001
item = molas tipo 2
preco = 5.92
quantidade = 10

My row in the table has a limitation of only 5 columns. I already managed to generate a table that repeats the lines based on the quantity value, the problem is that when the quantity is = 10 as in the example above, it creates 10 rows of 5 columns and I need only two rows.

If for example the quantity is = 7, will have to fill a row and complete the row with data from other items, which have quantity = 1, 3, 5 etc. Any hint?

  • Could put the code that generates these tables?

  • How do you find out how many rows (records) your table will have? It will always be two rows? How will it be?

  • Look Shura16 then, there is no standard because the quantity can vary a lot, few times I will have two or more lines of the same product, most of my products have quantity <= 5, can be 1, 3, some have above 10, there is no standard.

No answers

Browser other questions tagged

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