Invalid argument on foreach()

I am try to run a foreach else in the 2nd div col… the first div col runs great but on the 2nd div i get

Warning: Invalid argument supplied for foreach()

[php]

$stmt = $connection->prepare(“SELECT * FROM games JOIN mods USING(GameID)”);
$stmt->execute();
$result = $stmt->get_result();

while ($row = mysqli_fetch_assoc($result)) {

    $GameID = $row['GameID'];        
    $GameName = $row['GameName'];
    $GameCover = $row['GameCover'];
    $ModName = $row['ModName'];
    $ModCover = $row['ModCover'];

echo "


$GameName



";
echo "<div class='row'>"; 

   foreach($GalleryImage as $item){
       if(array_key_exists($item)) {

         echo "<h1>ModName</h1>";
         echo "<img src='$item'>";

       } else {
           echo "NO MODS";
       }
   }           

 echo "</div>";            

}

[/php]

Aside from going about this the wrong way, you cant just invent a variable and expect it to have data. Where do you come up with $GalleryImage?

Did not event any variable i now the $GalleryImage $ModCover… :stuck_out_tongue: wont let me modify it

Sponsor our Newsletter | Privacy Policy | Terms of Service