Sponge Bob Sponge Bob - 1 year ago 73
PHP Question

How to use php variable inside a javascript code in a php code?

How can I implement this:

echo "<script type='text/javascript'>";
echo "document.getElementById('table_apps').innerHTML = json_encode($td_temp);";
echo "</script>";

There is a problem with $td_temp;

Answer Source

json_encode() is a PHP function

Do like this

echo "document.getElementById('table_apps').innerHTML ='".json_encode($td_temp)."';";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download