Hello everyone,
The content for the pages on my site are stored as text in a MySQL database. I have a rudimentary editor in my admin section that allows me to edit the HTML. For instance,
<p>This is my content</p>
<p>... and this is more content</p>
The above block is saved as a field called ‘content’ in my ‘pages’ table.
I would like to add a PHP code snippet into the middle of this code. For instance,
<p>This is my content</p>
<p>Next tuesday will be <?php echo date( "Y-m-d", strtotime("next Tuesday")); ?>.</p>
<p>... and this is more content</p>
Here’s what I was thinking…
Save the following in my database…
<p>This is my content</p>
<p>Next tuesday will be [~Next Tuesday~]
<p>... and this is more content</p>
Then use the following code to display the text properly
echo str_replace("[~Next Tuesday~]", date( "Y-m-d", strtotime("next Tuesday")), $result['content'])
Any thoughts about making this better/more efficient?