Jump to content
  • Advertisement
Sign in to follow this  
bargasteh

[web] Load something from MySql into HTML using PHP

This topic is 4345 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 ?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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 ?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!