You really shouldn't be mixing php code into your smarty templates as the whole purpose of smarty is to separate code from html.
However Smarty has no mysql functions I know of, so to do it in the template you would have to use {php}{/php} to allow you to execte php code and then use php's mysql functions like mysql_connect(), mysql_db_query(), etc...
I recommend since you are starting though to start the right way and use adoDB or another db abstraction layer class to keep things portable and clean.
Do your SQL in the php file and assign it to whatever variables you need to access it with in smarty. Don't tdo your SQL in the template.
