Show data array

Asked

Viewed 125 times

0

I have the following data obtained from a query: inserir a descrição da imagem aqui

I would like to read this data and show it on the screen, but first show all the goals, then show all the challenges and so on.

<?php 

$resultado = ibase_query($CONEXAO_TERM, QueryDashGraf1(substr($loja_selecionada, 0,3),$data_dash, $data_inicial,$ultimo_dia_f));//executa query e armazena o resultado em um array

while ($dash = ibase_fetch_row($resultado)){
 echo trim($dash['0']);
   
}
while ($dash = ibase_fetch_row($resultado)){
 echo trim($dash['3']);

}
?>

Doing so, the second While is not shown.

How do I make the data appear correctly on the screen?

  • I can’t understand what you want to explain better ?

  • I think I got it, you want to list the values in the order DSMTE, DSDESAFIO, that in lines, for example list all DSMETA, then list all DSDESAFIO?

  • Exactly ... in the first Whilelistar all DSMETA, in the second While list all DSDESAFIO, and so on.

  • The way it lists only the data of the first While in the case of DSMETA.

  • I’ll answer a test tell me the result of it.

1 answer

1


In this example I’m creating a bi-dimensional vector, where the key is column and the value is an array of column values after I print everything. in the case and only one test, then just suit your case.

<?php 

$resultado = ibase_query($CONEXAO_TERM, QueryDashGraf1(substr($loja_selecionada, 0,3),$data_dash, $data_inicial,$ultimo_dia_f));//executa query e armazena o resultado em um array

while ($dash = ibase_fetch_row($resultado)){
    foreach ($dash as $key => $value) {
        $array_return[$key][] = $value;
    }

}
foreach ($array_return as $key => $sub_array) {
    foreach ($sub_array as $key => $value) {
        echo trim($value);
    }
}
?>

inserir a descrição da imagem aqui

  • Some questions: Have a foreach inside the while and others outside, what are their functions??

  • The first while I traverse each row, the foreach I traverse each item of the line creating an array, so that all DSMETA values, will stay in the array, for example: $array_return[''DSMETA][0] = 500,000,000, and so on. worked ? or returned error ?

  • I put my line like this: $array_return['PERIODO'][0] = $Dash[3]; supposing I want to list the periods. So I listed only one data.

  • if so, do not have to put the [0] so it will assign a new position for each certain would be just $array_return['PERIODO'][] = $dash[3];. you managed to understand the logic of what I did and it returned something ? as I have no access to the bank and more complicated.

  • If I put $array_return[$key][0] = $Dash[3]; returns 2018/092018/092018/092018/09. I would like all DSPERIODO values to appear.

  • you just want the DSPERIODO values ?

  • At first pass yes .... then do another while only with DSMETA values and so on

  • Do me a favor, bass the first while putting this here echo "<pre>"; var_dump($array_return); and take a print and paste the link here.

  • I edited the question and put the print at the end

Show 5 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.