Page 1 of 1

How do I output information from a PHP page to an HTML page?

Posted: Fri Jan 09, 2009 4:12 pm
by guitarscn
I have a .php web page with these lines:

Code: Select all

//gather all the comments
$commentquery = mysql_query("SELECT * FROM comments WHERE tutorialid='$tutid' ORDER BY date DESC") or die(mysql_error());
 
//count all the comments for the total
$commentNum = mysql_num_rows($commentquery);
I want the value of $commentNum which is going to be a number, to be displayed on another page that's written in HTML (.html extension) from the .php page.

How can I transfer this number over?

Re: How do I output information from a PHP page to an HTML page?

Posted: Fri Jan 09, 2009 5:02 pm
by logik
change the .html to a .php

or add this to your .htaccess file

Code: Select all

RewriteEngine on
RewriteRule ^(.*)\.htm$ $1.php [NC]
then all files with a .html extension will be parsed as php files

Re: How do I output information from a PHP page to an HTML page?

Posted: Fri Jan 09, 2009 11:43 pm
by califdon
You need to understand that .html pages are static pages--whatever you put into the .html file is what is sent to the browser. If you want to have variable data in a page, it should be a .php script.