siabanie Posted July 12, 2011 Share Posted July 12, 2011 Hi all, I wonder if anyone could help me out; I have this page say sitemap.html and I like to covert my covertsitemap.php code output to HTML (sitemap.html) Can anyone assist me please how this can be done? Thanks alot! Quote Link to comment https://forums.phpfreaks.com/topic/241816-how-to-convert-php-code-output-to-html/ Share on other sites More sharing options...
Maq Posted July 12, 2011 Share Posted July 12, 2011 We need more information. That doesn't make any sense to me. Quote Link to comment https://forums.phpfreaks.com/topic/241816-how-to-convert-php-code-output-to-html/#findComment-1241853 Share on other sites More sharing options...
siabanie Posted July 12, 2011 Author Share Posted July 12, 2011 Ok sorry for the lack of explanation; I try again. Basically all I want is -- "PHP code output to HTML" - I want to convert the output of PHP code (conversitemap.PHP) to sitemap.HTML. Here are the snippets of my code: adminSitemap.php <?php function sitemapFunk() { global $host, $sqlUser, $sqlPass, $database; mysql_connect ($host, $sqlUser, $sqlPass) or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ($database); $result = mysql_query("select * from cer_galleryInfo where display!='No' order by second, first ") or die (mysql_error()); .. .. .. $sitemapHTML .= "<li><a href='artistInfo/entry_".$row['keynum'].".html'>".ucfirst($row['first'])." ".ucfirst($row['second'])."</a></li>\n" ; } $html2write .= "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n"; $html2write .= "<html>\n"; $html2write .= "<head>\n"; .. .. .. $html2write .= " <h2>Exhibitor Gallery</h2>\n"; $html2write .= " <UL TYPE=\"circle\">\n"; $html2write .= "$sitemapHTML"; $html2write .= " </UL>\n"; .. .. $html2write .= "</html>\n"; $write = fopen("../sitemap.html","w"); fwrite($write,$html2write); } } ?> How can I just displaying the output that I have created in PHP in my HTML site (sitemap.html)? Quote Link to comment https://forums.phpfreaks.com/topic/241816-how-to-convert-php-code-output-to-html/#findComment-1241858 Share on other sites More sharing options...
ignace Posted July 12, 2011 Share Posted July 12, 2011 echo $html2write; Quote Link to comment https://forums.phpfreaks.com/topic/241816-how-to-convert-php-code-output-to-html/#findComment-1241859 Share on other sites More sharing options...
siabanie Posted July 12, 2011 Author Share Posted July 12, 2011 echo $html2write;??? I mean in e.g. sitemap.html --- How I can "extract or output" all the code in convertsitemap.php to my "html"? I cannot just write echo $html2write; and then save it in sitemap.html - That is a "PHP" code. Plus I do not need PHP code in my "html" any more as all I need is the output of the PHP code -- I already have my PHP code in convertsitemap.php so I need to know how to output them in HTML. Quote Link to comment https://forums.phpfreaks.com/topic/241816-how-to-convert-php-code-output-to-html/#findComment-1241864 Share on other sites More sharing options...
premiso Posted July 12, 2011 Share Posted July 12, 2011 $fh=fopen('sitemap.html', 'w'); fwrite($fh, $html2write); fclose($fh); Pretty simple. Quote Link to comment https://forums.phpfreaks.com/topic/241816-how-to-convert-php-code-output-to-html/#findComment-1241866 Share on other sites More sharing options...
siabanie Posted July 13, 2011 Author Share Posted July 13, 2011 So you are saying..I have to put this code: $fh=fopen('sitemap.html', 'w'); fwrite($fh, $html2write); fclose($fh); in sitemap.html? As you notice and look carefully -- I already have those code line adminSitemap.php Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/241816-how-to-convert-php-code-output-to-html/#findComment-1242134 Share on other sites More sharing options...
premiso Posted July 13, 2011 Share Posted July 13, 2011 So whats the problem then? If it is not writing well, either A: permissions issue, B: Something else in the code is screwing it up and you need to post the full code for further help. Quote Link to comment https://forums.phpfreaks.com/topic/241816-how-to-convert-php-code-output-to-html/#findComment-1242188 Share on other sites More sharing options...
siabanie Posted July 13, 2011 Author Share Posted July 13, 2011 So whats the problem then? If it is not writing well, either A: permissions issue, B: Something else in the code is screwing it up and you need to post the full code for further help. The problem is; my sitemap.html still not showing the values I have in convertsitemap.php. I wonder if you saying that: I have to save this code in PHP or HTML extension? as the sitemap is in HTML not PHP - all my PHP works done in conversitemap.php. $fh=fopen('sitemap.html', 'w'); fwrite($fh, $html2write); fclose($fh); If you said it might be the permission issue: How I can solve this? Basically my sitemap.html is just a HTML code no PHP code in it.. I do not think I should have those code you suggested put in my sitemap.html do you, what you think? Quote Link to comment https://forums.phpfreaks.com/topic/241816-how-to-convert-php-code-output-to-html/#findComment-1242196 Share on other sites More sharing options...
ajlisowski Posted July 14, 2011 Share Posted July 14, 2011 Im confused as to why this is needed, unless this is a weird way of doing some caching. Perhaps if you can explain why you want this to occur I can get a good idea of what you need to do to accomplish it. Quote Link to comment https://forums.phpfreaks.com/topic/241816-how-to-convert-php-code-output-to-html/#findComment-1242820 Share on other sites More sharing options...
siabanie Posted July 14, 2011 Author Share Posted July 14, 2011 Thanks all, I sort of figured this out - I am not 100% sure but by change the permission to 777 does the job "for now" - but it is still not 100% output all the recent data when say someone add a new record or delete the exist record. Will have to find out another way I guess. But thanks! ^^ Quote Link to comment https://forums.phpfreaks.com/topic/241816-how-to-convert-php-code-output-to-html/#findComment-1242859 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.