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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
guitarscn
Forum Newbie
Posts: 7
Joined: Wed Jan 07, 2009 2:59 am

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

Post 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?
logik
Forum Newbie
Posts: 8
Joined: Fri Jan 09, 2009 4:33 pm

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

Post 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
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

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

Post 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.
Post Reply