Well .. I need to do a search on a table and through that search pull the data from another. But I ended up losing myself 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 entered.
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 input screen I check if the data entered is in tabela Nota
. And if in case I make a select
by taking the sequencia
of this note typed and compare it with the fk_nota
that I have in another table, in order to get 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 get the sequence of a text field and compare with the fk that is 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