Forum Academy Marketplace Showcase Pricing Features

Using database to build a html code

I have two databases, like this:
Product: name, description, price
Emails: list of products
On my wokflow, the user can create an Email and add products to it. By clicking on “Generate email”, I want to assemble a HTML code for each item of the list of products, like this:
[p]product name[/p]
How can I use database information to build HTML code and then render it on the screen?