there are many functions like this already written, much like the ones in phpbb (which is open source) that you could use...
its something called bbcode, since php and sql translate conventional html tags into html....
on more advanced boards, they use java to simply insert the bbcode when you click the button...in your case it may be easier just to include some notes on your basic bbcode...
use a tag like [b] bold words [/b] to represent bold text, and when your script calls this data from the database have a function that translates the bbcode back into html tags...IE, have a function find all instances of [b] and [/b] and turn it into <strong> </strong>
please note: the escaped characters, "\" are not to be included in your implementation of the script, I only put them there so that this board wouldnt translate that stuff in the way I described
etc...