Hi,
I am making an assumption with respect to your database query in terms of variable names used:
// $numberOfImages is the first field
// $link is the second field
// Get extension of image including the .
$ext = strrchr($link, ".");
// Extract the first link to the image excluding the extension
$orgLink = substr($link, 0, strripos($link, '.', 0));
// loop over the additional images
for($xNr=2; $xNr<= $numberOfImages; $xNr++)
{
// These are the additional image links
$nextLink = $orgLink . '_' . $xNr . $ext;
}
This is just to give you an idea on how to create the additional links, i.e pure string manipulation. I noted that you switched numbering syntax from fileNameX to fileName_X but it is easy enough to adapt.