Jump to content

How to convert PHP code output to HTML


siabanie

Recommended Posts

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)?

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.

 

 

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?

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! ^^

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.