I'm looping through some data to display on my page, and then insert each loop to a row in a database (personal learning exercise for PHP and MySQL).
The for loop runs 5 times (for example, sometimes it may loop more/less), and I am able to successfully insert the data for the first 4 loops, but am having difficulty figuring out why the last loop won't insert into the database.
All 5 loop iterations display on my page, I'm not quite sure why the last loop won't insert into the database.
Here is my for loop that includes the MySQL code:
$artworksIterations = 1
count($artworksTitle[$x]) = 5
for ($x = 0; $x < $artworksIterations; $x++) {
    for ($y = 0; $y < count($artworksTitle[$x]); $y++) {
        $savedartworksTitle = $artworksTitle[$x][$y];
        echo "TITLE: " . $savedartworksTitle . "<br>";
        $savedartworksArtist = $artworksArtist[$x][$y];
        echo "ARTIST: " . $savedartworksArtist . "<br>";
        $savedartworksYear = $artworksYear[$x][$y];
        echo "YEAR: " . $savedartworksYear . "<br>";
        $savedartworksMedium = $artworksMedium[$x][$y];
        echo "MEDIUM: " . $savedartworksMedium . "<br>";
        $implodeGene = implode(", ", $artworksGene[$x][$y]);
        echo "GENRES: " . $implodeGene;
        $savedartworksDisplay = $artworksDisplay[$x][$y];
        echo "<br><img src='" . $savedartworksDisplay . "'><br>";
        echo "<br>----<br>";
        $sql = "INSERT INTO Artworks (title, artist, year, medium, display, genres) VALUES ('$savedartworksTitle', '$savedartworksArtist', '$savedartworksYear', '$savedartworksMedium', '$savedartworksDisplay', '$implodeGene');";
        mysqli_query($conn, $sql);
    } // end of y
} // end of x
Any help would be deeply appreciated. Thank you :)
