0
I have the following question, I have a table in the bank that cannot be changed to facilitate the process. In this table I have records parents and children with the possibility of up to 8 levels. More or less like this, as in the scheme below:
In this example, 123 is original code, which generates 1015, then 1015 becomes origin and generates 2016 and so on, I don’t know if it’s clear? My problem is in searching the values, I’m trying to create a way to search history the original value until I got something, but the user who search for the destination and return the hierarchy in the same way he searches 123 and returns all the way to 2016.
In my case the error happened when the user tried to fetch the value 3017 which is in the example the final destination, and I am not able to create a code return the final values.
My code so far:
function get_origem($con,$origem){
$sql = "SELECT * FROM tabela WHERE origem = '$origem'";
$movimentacao = ifx_query($sql,$con) or die(ifx_errormsg());
$row = ifx_fetch_row($movimentacao);
// Aqui insiro os valores em uma tabela temporária e depois listo ela com JOIN com outras tabelas.
// E chamo a função novamente para pegar o próximo filho.
get_origem($con,$row['destino']);
}
PHP and Informix usage.