I am wanting to automatically display content from my databse within an iframe as it acts as the body content which was submitted when creating the doc.
I am trying to insert with a mix of JS Php like so:
<iframe name="editor" id="editor" class="doc_body" ></iframe></div>
<script>
var iframe = document.getElementById('editor'),
iframedoc = iframe.contentDocument || iframe.contentWindow.document;
iframedoc.body.innerHTML ="<?php echo ($row[2]); ?>";
</script>
I know that I am indexing correctly because if I echo this out of the JS it will output the correct row.
Unless the syntax is wrong above?
UPDATED
so after some messing around it would appear that there is a conflict between this:
<?php
$q = "SELECT * FROM cats";
$r = mysqli_query ($dbc, $q); // Run the query.
// FETCH AND PRINT ALL THE RECORDS
while ($row = mysqli_fetch_array($r)) {
echo '<ul><li><label><input type="checkbox" <?php if ($checked == 1) echo "checked"; name="cat_id[]" value="' . $row['cat_id'] . '"> ' . $row["cat_name"] . '</label></li></ul>';
}
?>
And the above, If I remove this above the content shows but if I include it - it takes it away?