How best to store the html for embedding?
the only ways I can think of are:
take the embed html and add <?php echo $var1; ?> where the id’s go then store it in the db and use Eval to execute it.
or
insert a strange combination of characters to act as a marker to be replaced in php by the id’s.
Option #2 is much safer – just in case someone manages to execute a SQL injection attack against your DB, they can’t then exploit your embedding operation to execute injected PHP on the server side. The best they could hope for would be a phishing or XSS attack.
Another alternative is to format the appropriate data in XML and store in the database an XSLT to transform the data into the right embed code. That’s probably overkill for your case, but more scalable and less error-prone than either of the above.
EDIT: Skeleton code for XML version
XML
XSLT
PHP
The nice part about this is that you can create a class to generate the input XML, and it can contain all the parameters you want to pass to your
<embed>tag. If you don’t add processing instructions to your XSLT to handle them, they’ll be silently ignored. Make one class to generate the basic XML, and a subclass per media type you want to display, and generating the XML to pass the transforms should be easy.