One thing I notice is that in both loops, $gallery is given a new value every run through the loop, throwing away the value it was given the previous run through the loop. After all that, it will only contain whatever was put in it in the last run through the loop.
On the subject of capitalisation; variable names, unlike function names, are case-sensitive, and it is good practice to be consistent in how they're named. Compare $QUERY, $sql_query, $V, $Rez, $item['amt_stock'], and $row['Gallery_Name']; and I mention the last two especially because $row['Gallery_Name'] is used without being given a value if $item_list is not empty.