2
Well. I need to do a search in one table and through this search pull the data from another. But I ended up getting lost in logic ...
Example of what I’m doing:
The user informs the data he wants:
<td >
<font >Nota:</font>
</td>
<td >
<input name="tx_nota_fisc" type="text" maxlength="15" size="10" value="">
<button type="button" style="width:30" onClick="f_veri_nota();"><image src="../sai_imag/ref1.ico" > </button>
</td>
f_veri_nota()
calls the next screen by passing the data that was typed.
w_tx_nota = document.sai_frm_alte_novo_cara_peri.tx_nota_fisc.value;
document.getElementById("ifrm_peri").src = ("sai_frm_alte_novo_cara_peri1.php?w_tx_nota="+w_tx_nota);
And in the screen input I check if the typed data is in the tabela Nota
. And in case I do select
catching the sequencia
of that typed note and compare it with the fk_nota
that I have in another table, so take the data.
<?
$w_tx_nota = $_GET['w_tx_nota'];
$w_querybusca = "select * from sai_nota where num_nf = '$w_tx_nota';"; --> verifica se existe o dado digitado na tabela
$w_querybusca = "select " --> E nesse select quero pegar a sequencia do num_nf e comparar ele com uma fk que se encontra em outra tabela. Para assim popular os campos.
?>
The problem: How to take the sequence of a text field and compare it with the fk in another table?
Structure:
create table sai_nota
(
sequencia_nota integer not null,
num_nf character varying(9)
)
create table peri
(
sequencia_peri integer not null,
fk_nota serial not null,
//outros campos
)
*Fictitious names
I couldn’t quite grasp your question. Could you rewrite it or explain it better?
– GustavoAdolfo
It’s like you have the name and the Cpf in one table and the rest of the individual’s information in another table?
– Marcos Vinicius
You can include in the question the structures of the tables involved, so we understand better?
– bfavaretto
That’s right @Marcosvinicius, and Cpf is like fk in that other table!
– Bruno
You can or want to do all this in one query and send the result to the other page @Bruno?
– Marcos Vinicius
It could be in a single query, because I think it would be a simpler way to work @Marcosviniciusnasc.Pereira!
– Bruno
The crowd is already responding but improves the name of these attributes/variables, both in the bank and in the code I guarantee you will not regret. From a read on "Names of variables..."
– Trxplz0
I mentioned in the question, these are "fictitious names" !
– Bruno