First you would create the html page containing a form that has an action pointing at some cgi script.
Next you create the cgi script.
In this cgi script, first you would utilize a
module to parse the cgi data and obtain the form parameter from the html page.
Next you would use
dbi to connect to your database.
After that you would create some sql that fetches you the proper results: this sql is likely to be server specific so examine your server's manual.
Nextly you would execute this sql and retrieve the results.
Lastly you print out the appropiate header and any html to display the results you retrieved.