[web] Load something from MySql into HTML using PHP

Started by
7 comments, last by icap 17 years, 9 months ago
Hello, I have a question. imagine I have a XHTML website and I want to load some news from MySQL and show it on that XHTML using PHP. how can I do this ? is it possible or I have to do that entirely on PHP ? I am not sure if my question is clear. Thanks for your help
OpenGl + C++
Advertisement
perhaps possible to do in XHTML but far far far far infinitely easier in PHP. PHP has build in libraries and such via which you can connect to an SQL database, run queries and nicely serve a dynamically populated page.
This is exactly what I mean.

Imagine I have a index.html as my main page. then I have a news.php that can read news data from a MySql database. now I want to populate my index.html with those news data that my news.php has queried from MySql.

Is this possible ?
OpenGl + C++
Try this w3schools tutorial. That explaints the basis of PHP-MySQL interaction.

PS: Why do you want to have index.html? You can serve XHTML pages directly from PHP.

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

yeah. you'd have an index.php which generates all your happy content. no need at all for .html files. PHP generates the output for you. funtimes

-me
I wanted to do that because I already made a index.html I didnt want to put them all on a Php file.

I think I am going to do that because that is the only way, isnt it ?
OpenGl + C++
Well, in theory you can have a backend written in PHP that generates static HTML pages for you from the MySQL content, but that's in 99% of the cases not worth your trouble. Just make it a PHP powered site and use mod_rewrite to map your old URL's to your new URL's so you don't get 404's.

<hr />
Sander Marechal<small>[Lone Wolves][Hearts for GNOME][E-mail][Forum FAQ]</small>

Just rename index.html to index.php and you could either put the news code directly in the index file or do something like news.php (news.inc.php actually) and use an include in the index page.
or use php and mod_rewrite to rename all php extensions to html or any other extension you like, without loosing functionality!

need a example ? www.capix.nl using PHP in combination with mod_rewrite :)
Capix > Advanced Warfare < www.capix.nl

This topic is closed to new replies.

Advertisement