Okay. First off do you know how to create a module in phpVMS?
Secondly, in first stack of codes, where are they located right now. This is important.
Third, variable "$id" where do you get the value for it? where is the rest of the code?
Forth, in second stack of codes, you're missing a loop to go through the results back from data base.
Fifth, You have a lot of issues with your code to resolve.