{"id":5513,"date":"2018-01-19T19:31:23","date_gmt":"2018-01-19T19:31:23","guid":{"rendered":"http:\/\/goofy-trucks.flywheelsites.com\/display-php-generated-content-on-non-php-pages\/"},"modified":"2018-01-19T19:31:29","modified_gmt":"2018-01-19T19:31:29","slug":"display-php-generated-content-on-non-php-pages","status":"publish","type":"post","link":"https:\/\/phpbuilder.com\/display-php-generated-content-on-non-php-pages\/","title":{"rendered":"Display PHP generated content on Non-PHP pages"},"content":{"rendered":"<div class=\"phpbuilder-content\">\n<div class=\"phpbuilder-meta\">\n<div class=\"\">By chris<\/div>\n<div class=\"\">on May 26, 2003<\/div>\n<\/p><\/div>\n<div id=\"overflow-content\">\n<p>Ever wanted to get some database content or server side scripting output onto<br \/>\na plain old HTML (non-php) page?<\/p>\n<p>I wrote a link database script in PHP that I wanted to share with other web<br \/>\n  sites. But most of these web sites were written in HTML, not PHP. I discovered<br \/>\n  that I could call a PHP file using JavaScript to display my database of links<br \/>\n  on other peoples web sites.<\/p>\n<p>All that is required is that your PHP script be on a server running PHP and<br \/>\n  that the output of the PHP script be valid JavaScript.<\/p>\n<p>Anyone who wanted to use my database<br \/>\n  of links just needed to place this script in their HTML where they wanted to<br \/>\n  display the content:<\/p>\n<p><code>&lt;script language=\"JavaScript\" type=\"text\/javascript\" src=\"<a href=\"http:\/\/mydomain.com\/scripts\/db_links.php\">\" target=\"_blank\" target=\"_new\"&gt;http:\/\/mydomain.com\/scripts\/db_links.php\"&gt;&lt;\/script&gt;<\/a><\/code><\/p>\n<p>My PHP script looked something like this:<\/p>\n<p><code>&lt;?PHP<br \/>\n    function get_links(){<\/code><\/p>\n<p><code>\t\/\/ get data from database<br \/>\n    $result=mysql_query(....<\/code><\/p>\n<p><code> \/\/ store formatted data into a variable<br \/>\n    $content.= ....<\/code><\/p>\n<p><code>}<br \/>\n    ?&gt;<br \/>\n  <\/code><\/p>\n<p><code>&lt;!-- Hide from non JS enabled browsers<br \/>\n    \/\/ Use JavaScript to write content to<br \/>\n      screen<br \/>\n    document.write('&lt;?PHP echo $content; ?&gt;');<br \/>\n    \/\/--&gt; End Hide<\/code><\/p>\n<p>That was it. I was surprised at how easy it was.<\/p>\n<p>Hope it helps someone else.<\/p>\n<\/div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Ever wanted to get some database content or server side scripting output onto a plain old HTML (non-php) page? I wrote a link<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-5513","post","type-post","status-publish","format-standard","hentry","category-tips"],"_links":{"self":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/5513","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/comments?post=5513"}],"version-history":[{"count":1,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/5513\/revisions"}],"predecessor-version":[{"id":5651,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/posts\/5513\/revisions\/5651"}],"wp:attachment":[{"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/media?parent=5513"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/categories?post=5513"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/phpbuilder.com\/wp-json\/wp\/v2\/tags?post=5513"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}