I'm assuming you want to use the value in the shell variables as parameters for a database enquiry? Well then, what's the command you want to use for doing it with a single entry?
Configure that, then wrap a loop around it and substitute the variables you want to use as the inputs.
However, you'll probably want to use an array
for the shell script instead of single variables. Perhaps even an associative array.