Passing Var to a dailog

Passing Var to a dailog

I have a question if someone can please help me and show me how to do this.

I have a web page that is in php. when someone clicks on a <span></span> elem, I need to passed a var to a jQuery dialog box that will then access a database to get information to be displayed.

Can this be done and how can I do it.