在PHP中更新标记的innerHTML属性

I am trying to update innerHTML property of paragraph tag in PHP. I made a rest API call that gets the date and after parsing it. I am adding the result(HTML table constructed by parsing the results from API) to a <P> tag already in page. I am using following PHP code to do so:

$dom = new DOMDocument();
$child = $dom->createElement('p',$myresult);
$dom->appendChild($child);
$dom->SaveHTML();

$myresult is the string that contain html table with information. The above lines are executed smoothly but no change in p tag content.

I tried this too, but no change in output:

<?php echo "<script>document.getElementByID("#id").innerHTML = ". $myresult."</script>"

Am I doing anything wrong?

Try:

<?php echo "<script>document.getElementById(\"id\").innerHTML=".$myresult."</script>" ?>

as long as id is an existing html element id and $myresult is a php variable containing html

OR

You may try

<div id="id"><?php echo $myresult; ?></div>

Notes:
1. It is getElementById() not getElementByID()
2. Usually #id is used in jquery, and in pure JS it is just id

try this

<?php echo "<script>document.getElementByID(\"id\").innerHTML = ". $myresult."</script>" ?>

you need escaping quotation on getElementByID and u dont need #

You should escape double quotes inside a double-quote string in PHP. But, you can as well use single quotes instead like so:

<?php echo "<script> document.getElementById('id').innerHTML = '$myresult' </script>"; ?>

Also, it is getElementById not getElementByID. And remove the # from getElementById().