1
I have the following tables
draw and games in a particular Mysql database.
In the draw table, are stored the data of the contest number, drawn 1st decade, 2nd, 3rd, 4th and 5th decade.
draw table
+------------------------------------------------+
| competition | so1 | so2 | so3 | so4 | so5 |
+------------------------------------------------+
|. . 3916 ... | 13 ..| 26 .| 44 .| 64 ..| 68 ..|
+------------------------------------------------+
On the table games, is stored the cards played, containing the dice as number of the contest of the draw, 1st to 5th scored. each game contains an identified called id_games which is the P.K table.
table games
+--------------------------------------------------+-----+
| contest | id_matches | jo1 | Jo2 | Jo3 | jo4 | jo5 |
+--------------------------------------------------+-----+
|. . 3916 ... | . 01 . . . | 13 | 28 . | 44 | 68 | 69 .|
+--------------------------------------------------+-----+
|. . 3916 ... | . 02 . . . | 13 | 28 . | 44 | 68 | 69 .|
+--------------------------------------------------+-----+
|. . 3917 ... | . 03 . . . | 13 | 28 . | 44 | 68 | 69 .|
+--------------------------------------------------+-----+
<?php
// Variável recebida referente a consulta
$consulta = $_POST["consulta"];
// variável que conecta ao banco
$pesquisa = $conn->prepare
("SELECT * FROM SORTEIO INNER JOIN JOGOS USING(CONCURSO)");
$pesquisa->execute();
$resultado = $pesquisa->fetchAll(PDO::FETCH_ASSOC);
// laço para buscar coluna id_jogos, o valor de cada cartela.
foreach($resultado as $r ){
if ($r['concurso'] == $consulta){
// aqui dentro desse laço quero retornar as dezenas acertadas de cada jogo. exemplo, ao consultar o concurso 3916, encontro três jogos na tabela jogos. são as id_jogos 01 e 02. Na id_jogos 01 há três resultados que se repetem, isso quer dizer que acertei três dezenas. exibo os valores acertados, e passo para o id_jogos 02 realizar outra consulta e exibir os valores acertados. e assim sucessivamente, independente da quantidade de jogos tiver.
}
}
?>
What’s the matter?
– Marco Aurélio Deleu
Try to express yourself better, it’s not clear the problem.
– Bia
When explaining the columns of the table, put specific names of the columns for us to put in the answer, so it is very vague. Also paste a piece of code to make it clearer.
– Edson Horacio Junior
Noble friends @Marcoauréliodeleu sought to improve editing the post for a better understanding.
– Paparologia
Opa @Edsonhoraciojunior, edited for better understanding.
– Paparologia
@Pedropaparology OK Pedro, now you have explained the context, but it remains to explain what the problem is/what you want.
– Edson Horacio Junior
@Edsonhoraciojunior , worth is almost this, I want to return from each game the dozens individually hit. Ex: The scores hit from the game (id_games 01), there being another game in the same contest also display it separately. let’s say that in a given contest consulted, have 10 games, I want for each game related in the consultation, return me the tens hit.
– Paparologia
@Pedropaparology the code I posted already does this, just apply your visualization logic now: display in table or Divs, whether it will be all in a row or separate into rows, etc, but the logic is already correct.
– Edson Horacio Junior