Generating HTML from PHP

Associate
Joined
13 Nov 2003
Posts
1,567
Location
Manchester
Hi All

Working on an ebay template system that generates ebay listing templates.

Now what i need is to be able to generate HTML code using PHP recordsets etc. I can do this, the main problem is that I dont want to just load the page and leave the user to goto view source etc. I would like it show the source code in a text box. Also, as its an ebay template I would like to able to cut out the unecesary tags that appear a the top of the page.

I am storing all of the listing data in a DB so this can be called to populate the page

Any ideas would be appreciated
Aaron
 
Associate
OP
Joined
13 Nov 2003
Posts
1,567
Location
Manchester
Im not storing the actual HTML in the DB

Just the info that needs updating on the template.

I now have the page made and can generate the templates but I want to be able to display the HTML that the PHP server generates in a text box

Any ideas?

Thanks
 
Soldato
Joined
18 Oct 2002
Posts
5,464
Location
London Town
You could probably do it with output buffering, if I'm understanding you correctly.
Include the script that generates the HTML template and throw it into an output buffer. Then htmlspecialchars() the buffer contents (the generated template) and place it in a <textarea> or the pre-code block as above e.g.
Code:
<?php
ob_start();
include 'script_that_generates_the_template.php';
$template = ob_get_contents();
ob_end_clean();
?>
<html>
...
<body>
 <h1>Template</h1>
 <p>Your generated template code is in box below:</p>
 <textarea>
  <?php echo htmlspecialchars($template); ?>
 </textarea>
</body>
</html>
Untested, should work.
 
Last edited:
Back
Top Bottom