Why are you creating a new db object every time?
Just create it one (e.g. in an include file) and the just reference it. Just use the link_id reference, although if you just have one, you don't need to refer to it explicitly. Close the connection if you really need to at the end of your last sql call.
diafol
Keep Smiling
10,675 posts since Oct 2006
Reputation Points: 1,632
Solved Threads: 1,514
Skill Endorsements: 57
I like to avoid using globals if possible. If you're just using vanilla functions - the DB object should be available without the need to use global. If you're using classes, it may be more complicated. You mention using Smarty - I haven't used it for a couple of years, so I can't quite remember the pitfalls, but I can't imagine that it would present an obstacle as you sort out your variables in php before assigning them/setting the block to the html template.
I'm no expert I'm afraid - perhaps if you posted some key elements of your code, it would help.
diafol
Keep Smiling
10,675 posts since Oct 2006
Reputation Points: 1,632
Solved Threads: 1,514
Skill Endorsements: 57