I'm not sure what you mean:
Two things: First, you should not have a table for each gallery in your db, since in theory, that could require an infinite number of tables (same goes for columns in any one table).
A design that's compliant with standard ER-Models would be one (or two tables) with columns for image name, URL, description, ... plus either a column with the gallery name or else (in case of two tables) a foreign key referencing the gallery ID from the table that stores the gallery information. Two tables make sense when there's more than a name for each gallery (descriptive text, folder information, etc..). The focus of database design is, among other things, to avoid redundancy.
Second: Assuming your db is outlined as above, you connect to it using the standard PHP functions (check www.php.net for the description plus examples).
Then you execute a statement like "Select imgName, imgURL from images Where gallery = 'desiredGalleryName';" (for 1 table) or else
"Select imgName, imgURL from images, galleries Where images.gID = galleries.ID AND galleries.Name = 'desiredGalleryName';"
With the results of this query, you can then build a table using a while loop.
Hope that helps. Let me know either way 😉