I'm quite sure Rulian is on the right track concerning placement of code. Since I don't have any code to look at, I suggest you read through your code and figure out how it SHOULD work. Something like this :
<?php
if(dbtable is invalid or not set) {
set dbtable to my defaulttable
}
show a dropdown with allowed tables + the defaulttable and highlight the selected
if (action == query) {
make some sql-query using the dbtable
show result
} else {
show some help about how to use the script
}
?>
Does it make any sense? Atleast it would be one way that I would make the script work (if I've understood your wishes correctly? s)