0
Person, I’m new to the Forum I’d like to ask for first aid. Summarizing: I’m developing a call system, where it gathers data from other systems.
I would like to display all data from 2 sql tables in a php tebela, each row there is information from a table.
- table 1
- table 2
- table 1
- table 2
I only found information about John, but this would not help me because it gathers the data in the same column, and I would like separate lines for each table of the database.
I’m doing like this:
<?php
$servidor = "localhost"; /*maquina a qual o banco de dados está*/
$banco = "xxxx"; /*seleciona o banco a ser usado*/
$usuario = "root"; /*usuario do banco de dados MySql*/
$senha = ""; /*senha do banco de dados MySql*/
$conexao = mysql_connect($servidor,$usuario,$senha);
/*Conecta no bando de dados MySql*/
mysql_select_db($banco);
/*seleciona o banco a ser usado*/
$res = mysql_query("SELECT * FROM base_itg, base_spn");
/*Executa o comando SQL, no caso para pegar todos os chamados e retorna o valor da consulta em uma variavel ($res) */
?>
and then put on the screen
while($escrever=mysql_fetch_array($res)){
$id = $escrever['id']; /*Escreve cada linha da tabela*/
echo "<tr>
<td> <a href = 'detalhe.php?id=$id' target =_blank>" . $escrever["bl_situacao"] . "</td>
<td>" . $escrever["bi_sistema"] . "</td>
<td>" . $escrever["bl_local_atendimento"] . "</td>
<td>" . $escrever["bl_uf"] . "</td>
<td>" . $escrever["bl_chamado"] . "</td>
<td>" . $escrever["bl_criado_em"] . "</td>
<td>" . $escrever["bl_resumo"] . "</td>
</tr>";
echo "<tr>
<td> <a href = 'pages/detalhados/spn.php?id=$id' target =_blank>" . $escrever["bs_status"] . "</td>
<td>" . $escrever["bs_sistema"] . "</td>
<td>" . $escrever["bs_sistema"] . "</td>
<td>" . $escrever["bs_sistema"] . "</td>
<td>" . $escrever["bs_sistema"] . "</td>
<td>" . $escrever["bs_sistema"] . "</td>
<td>" . $escrever["bs_sistema"] . "</td>
</tr>";
}/*Fim do while*/
I can show the data simultaneously, but with an error, it gets duplicated.
If by summing the data of the two tables I have 4 items, it shows 8.
but what I don’t understand is why I say pc.marca = c.marca, because they are two different things.
– Gabriel Dadda
i want to take all rows of 2 tables, and show 1 row under the other.
– Gabriel Dadda
I would like different lines, one with cell phone and the other with computer.
– Gabriel Dadda
better edit the question and explain the following: 1 - table structure, 2 - fields to be selected in the query, 3 - filter you want to use for selection
– SneepS NinjA
I rephrased my question, and posted the code for a better understanding.
– Gabriel Dadda
I’m still not going to give an answer because I didn’t understand one thing, your second echo will show 6 columns with the same information ?
<td>" . $escrever["bs_sistema"] . "</td>
that’s right ?– SneepS NinjA
Read this: Why shouldn’t we use mysql_*? http://answall.com/q/579/13561functions
– Ivan Ferrer
instead of Join, use Union, make two independent queries, and use Union to join them.
– Ivan Ferrer
This for now is a test, it is currently showing the same information. I appreciate the attention and I apologize for the formulation of my questionnaire, but I managed to solve my problem by putting a loop inside a loop;
– Gabriel Dadda
could not use UNION?
– Daniel Omine