You're missing the closing bracket and parenthesis in your anchor. Otherwise, without trying it, it appears solid at first glance.
EDIT: Looks like you're missing a comma between "pageinit" and function. and it's not a good idea to pass the POST parameters directly into your SQL query. That should be sanitized/verified as a valid value prior.