What approach should be used to save the current generated PHP page as an HTML file in the server database?
My PHP page is like a liquidation report which I want to save and it uses JavaScript to get generated, so buffering didn't work (ob_start and ob_get_contents).
Edit:
I use simple CSS styles and this JavaScript to give an effect of expand-collapse to some objects listed.
function showHide(HID,IMG) {
if (document.getElementById(IMG).src.indexOf('expand') != -1) {
document.getElementById(IMG).src='../../images/collapse.gif';
document.getElementById(HID).className='visibleRow';
} else {
document.getElementById(IMG).src='../../images/expand.gif';
document.getElementById(HID).className='hiddenRow';
}
}
Make your field type as text not varchar. Then youll be able to save html
Something like post the $(body).html()
via AJAX could probably do the trick.
$(document).ready( function(){
var data = $('body').html(); // and this can be used to store in database in blob or text field as u wish using AJAX
}
hope this might help you.
As I've commented on a lot of posts, I thought I should add an answer.
For the JavaScript, you should have something like:
$(document).ready(function() {
var page = $(document).html();
$.post("save_invoice.php", { page: page } );
});
For the PHP, use something like:
<?php
$page = $_POST['page']; // contains the posted page's content from javascript
mysqli_query("INSERT INTO invoices SET page='".$page."'");
?>
If there's any problems, try commenting.
Connor :)