Show PHP table data

Asked

Viewed 60 times

0

I have a problem, I wanted to show the data of the respective table the query that is made. I can only show the two values within the for cycle. What I want is to show the data outside of the for cycle, like save to an array and show 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;

                }

1 answer

1

create an empty variable of the Array type outside your loop. Then inside the for, use the array_push function to insert at the end of the variable the result found. To go through the variable use 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>";

}
  • I cannot show the data in the table.

  • You want to display the results IN a table or the results IN a table?

  • The results of a respective table the query.

Browser other questions tagged

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