Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to generate a HTML page dynamically using PHP?

I have a page which displays info about a property, based on the unique ID from the url, searching the mysql database for that ID, getting all the info from that row etc, fairly standard really.

I was wondering if/how I can 'create' a html page for each database row, as I'm assuming this would be better for SEO? Having multiple pages with keywords on rather than one dynamic page?

My properties are added to the database by a form/ upload system on the site, I was thinking creating the page on upload might be easiest, but am open to suggestions!

like image 222
rpsep2 Avatar asked Feb 14 '13 08:02

rpsep2


People also ask

How PHP helps in creating a dynamic website?

When a browser requests a PHP page, the web server sends the page to the PHP engine, a piece of software that runs on the server. This processes is the PHP code and merges the output with the HTML. And it's this merged output that's sent back to the browser.

Does PHP generate HTML?

PHP and HTML interact a lot: PHP can generate HTML, and HTML can pass information to PHP. Before reading these faqs, it's important you learn how to retrieve variables from external sources.


1 Answers

Just in case someone wants to generate/create actual HTML file...

$myFile = "filename.html"; // or .php   
$fh = fopen($myFile, 'w'); // or die("error");  
$stringData = "your html code php code goes here";   
fwrite($fh, $stringData);
fclose($fh);

Enjoy!

like image 79
Armand Avatar answered Oct 12 '22 03:10

Armand