Show data from the PHP table

0

I'm having a problem, I wanted to show the table data regarding the query that is done. I can only display the two values within the for loop. What I want is to show the data outside the for loop, type save to an array, and display that array.

for($y=2; $y>0; $y--){
                    $base_hndl  =   new SQLite3($dir.$base);                    
                    $requete    =   "SELECT id, title, start, end, description, jour, mois, annee, date 
                        FROM \"event\" 
                        WHERE jour=\"$i\"
                        AND id=$y";

                    $resultat   =   $base_hndl->query($requete);     
                    $affiche    =   $resultat->fetchArray();

                    $result = "<label><b>$affiche[title]</b></label><br>";

                    echo $result;

                }
    
asked by anonymous 03.11.2014 / 23:07

1 answer

1

Create an empty variable of type Array out of your loop. Then inside of for, use the array_push function to insert the result found at the end of the variable. To traverse the variable use the foreach

$array_resultados = array();
for($y=2; $y>0; $y--){
                        $base_hndl  =   new SQLite3($dir.$base);                    
                        $requete    =   "SELECT id, title, start, end, description, jour, mois, annee, date 
                            FROM \"event\" 
                            WHERE jour=\"$i\"
                            AND id=$y";
                    $resultat   =   $base_hndl->query($requete);     
                    $affiche    =   $resultat->fetchArray();
                    array_push($array_resultados, $affiche);

            }
foreach($array_resultados as $key =>$value){

                $echo "<label><b>".$value['title']."</b></label><br>";

}
    
04.11.2014 / 00:05