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!
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!
Not sure what your question is (mostly because it doesn't make sense).
PHP doesn't output anything that it isn't told to output, so if you want HTML output, then... output HTML.
perhaps you mean run php code in a file named *.html ??
dagon;10984209 wrote:perhaps you mean run php code in a file named *.html ??
Thanks for the feedback - well as I said; I would like to run the PHP code output to HTML. In the other way to say it, convert the output of PHP code to HTML.
Basically I have this sitemap.HTML and I have another file conversitemap.PHP - And I would like to just output the PHP code to HTML (sitemap)
Here is the snippets:
convertsitemap.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);
..
..
..
$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>Gallery</h2>\n";
$html2write .= " <UL TYPE=\"circle\">\n";
$html2write .= "$sitemapHTML";
$html2write .= " </UL>\n";
..
..
$html2write .= "</html>\n";
$write = fopen("../sitemap.html","w");
fwrite($write,$html2write);
}
}
?>
And the sitemap.HTML - is just a simple HTML code but I would like it to output the PHP code that I have created in convertsitemap.php.
Just so we're clear, the PHP is being used to connect to your database and retrieve the data, the HTML is giving a structure for the data to be presented in. If that doesn't make sense read this thread here, Deciding between PHP and HTML, NogDog has a good explanation.
To output the PHP you can just use echo(), you don't have to write it to a html file.
echo($html2write);
Alternative you can have an a file with an .html extension that has PHP embedded in it, but really makes sweet FA difference.
<UL TYPE=\"circle\">
<? php echo($sitemapHTML); ?>
</UL>
My code is giving error when I convert PHP code to HTML output. What to do??? The code is running perfectly with PHP.
If it works perfectly in PHP then leave it in PHP.
Emma;10984243 wrote:Alternative you can have an a file with an .html extension that has PHP embedded in it, but really makes sweet FA difference.
<UL TYPE=\"circle\"> <? php echo($sitemapHTML); ?> </UL>
Thanks for your reply, but I do not think we can have
<UL TYPE=\"circle\">
<? php echo($sitemapHTML); ?>
</UL>
and save it say sitemap.html as the code contain some PHP code. What do you think? I still not able to display the output on my sitemap.html, anyone?
do you need the html file to show in browser or just feed some other thing like Google crawler?
Is the output of the PHP code you've shown us static, or can it change? If it's static, just save the output as an HTML file.
If it's dynamic, then why does it matter if the file is called sitemap.php or sitemap.html or sitemap.whateveryoufeellikecallingthefile?
EDIT: If it's an external service/API/whatever that's specifically looking for sitemap.html, then just redirect requests for 'sitemap.html' to 'sitemap.php' (or whatever you've called the file).
Thanks guys,
The PHP code is static and the PHP code will do all the updating data e.g. if a new user add a record, delete or edit the record. Then the sitemap.HTML will display/output the current data.
I will try the permission 777 if this is the issue. Thanks again!
siabanie;10984307 wrote:The PHP code is static
All code itself is static... unless you've invented some new form of AI that writes PHP code for you on the fly. What I was asking about is the output, which appears to be dynamic based on your description of what it does.
siabanie;10984307 wrote:I will try the permission 777 if this is the issue. Thanks again!
Why would permissions be related whatsoever to anything mentioned in this thread?
bradgrafelman;10984311 wrote:All code itself is static... unless you've invented some new form of AI that writes PHP code for you on the fly. What I was asking about is the output, which appears to be dynamic based on your description of what it does.
Why would permissions be related whatsoever to anything mentioned in this thread?
I mention about "Permission" because maybe it could be the reason the output is not updated or something when sitemap.html is called.
Yes the output is dynamic - the point I am trying to say here is, as far as I know sitemap always has the extension HTML and is it correct that it has the benefit of google search?
siabanie;10984319 wrote:sitemap always has the extension HTML
Says who? And besides, "file extensions" aren't really relevant when it comes to URLs (since URLs don't have any correlation with file systems). That's why the HTTP protocol has headers like 'Content-Type' .
siabanie;10984319 wrote:and is it correct that it has the benefit of google search?
As far as I know, Google doesn't care what your URLs end with - ".html", ".php", or ".I_Really_Love_Watermelons" since it isn't relevant; it only cares what type of content (hint: see above) the URL is pointing to.
bradgrafelman;10984320 wrote:Says who? And besides, "file extensions" aren't really relevant when it comes to URLs (since URLs don't have any correlation with file systems). That's why the HTTP protocol has headers like 'Content-Type' .
As far as I know, Google doesn't care what your URLs end with - ".html", ".php", or ".I_Really_Love_Watermelons" since it isn't relevant; it only cares what type of content (hint: see above) the URL is pointing to.
Thanks bradgrafelman for the explanation... - In that case I closed this tread as a solved!
Thanks everyone!!