PHP How to make a specific loop for each table?

Asked

Viewed 76 times

-1

Good Afternoon

I have a table on MYSQL

 <?php 
 $pesquisa = "SELECT * From tabelaProdutos";

 ID / Código / Descrição /    Qtd
 1  /0001   / Caixa Azul 1/   1
 2  /0002   / Caixa Azul 2/   3
 3  /0003   / Caixa branca 1/ 12
 4  /0001   / Caixa Preta 1/  11

How do I make each loop I put a different condition.

I need the user to receive tables separated by description as the examples below.

Example Table 1

 ID / Código / Descrição /    Qtd
 1  /0001   / Caixa Azul 1/   1
 2  /0002   / Caixa Azul 2/   3

Table 2

3  /0003   / Caixa branca 1/ 12

Table 3

4  /0001   / Caixa Preta 1/  11

I need to make one SELECT for each table ? or has some easier and more correct way to do this ?

Thank you

  • Your question was not very clear, I did not understand very well what you need

  • There are three different comics tables?

  • No. I need to generate in html the 3 tables, but I would like to know for each table I need to create a different SELECT, or only a SELECT I can do the 3 tables in html

  • It gets complicated to say if we don’t know the conditions you want to use to separate the data into 3 sets.

  • By description, one for blue box, one for white box and one for black box

  • Actually whatever, you can do a single query and 3 loops, or 3 queries and 3 loops.

  • As an example I have this loop <?php while ($given = $result->fetch_array()) { ? >, how can I make the condition for the description

Show 2 more comments

2 answers

0

From what I understand you don’t want me to repeat the rows of the table when it is the same. Use the command below.

SELECT DISTINCT descricao
FROM tabelaProdutos

0

From what I understand you don’t want me to repeat the rows of the table when it is the same. Use the command below.

SELECT DISTINCT descricao
FROM tabelaProdutos
  • Actually this is not the table in html using a query and loop, need a query to make other loops with the condition of different descriptions

Browser other questions tagged

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