Site Statistics
 
Threads: 3,903
Posts: 17,128
Members: 2,911
Users Online: 17
Newest Member: rado123


Go Back   PC101 > PC Software > Software Development

Software Development Programming / Databases = C & C++, SQL & PL/SQL, Java Help and more!


Reply
 
LinkBack Thread Tools Display Modes
Old 11-12-2006, 08:49 PM   #1
Junior Member
 
Join Date: Nov 2006
Posts: 28
Rep Power: 0 peeling is on a distinguished road
Dynamic HTML Pages

Hi,

How do I create dynamic HTML pages? I need to keep a few pages HTML, but there's a few dynamic components which are also essential on the pages. Don't tell me to use frames. Also, the dynamic content comes from a mysql database.
peeling is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-12-2006, 10:56 PM   #2
Distinguished Member
 
Join Date: Jul 2005
Posts: 2,208
Rep Power: 6 Will.Spencer is on a distinguished road
Don't use frames.

Most dynamic content is delivered from Content Management Systems (CMSs), but it sounds more like you want to build your own CMS.

If that is true, then the answer to "How do I build Dynamic HTML Pages" is usually "use PHP."

PHP integrates especially well with MySQL.

Inside PHP, the functions which you will want to pay special attention to include:
  • mysql_connect()
  • db_select()
  • nysql_query()
  • mysql_fetch_row()
  • mysql_fetch_array()
  • mysql_close()
Will.Spencer is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-13-2006, 12:18 AM   #3
Junior Member
 
Join Date: Nov 2006
Posts: 28
Rep Power: 0 peeling is on a distinguished road
Problem is, my client is using PHP pages which get their data from a mysql database. But he has a lot of html pages which are very well indexed in google. He does not want to scrap the pages. He just wants to add some dynamic content to the html pages, along with their existing static content. I'm pretty sure it can be done, which is why I told him it can be done.

Now I want to know how it can be done.
peeling is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-13-2006, 09:20 AM   #4
Distinguished Member
 
Join Date: Jul 2005
Posts: 2,208
Rep Power: 6 Will.Spencer is on a distinguished road
You can call PHP from within HTML pages.

You have to configure httpd.conf to tell Apache to look for PHP in files with the .html extension.

This is done with an AddType declaration:

Code:
    AddType application/x-httpd-php .shtml
You then just have to put the PHP into the HTML files.

Code:
<?php
/*
This is PHP code.
*/
?>
Alternatively, I have also seen people call external PHP code using JavaScript, which seems to be interesting:

Code:
<script src='http://www.example.com/example.php' type="text/javascript"></script>

Another alternative is to use .php files and embed the existing HTML within them.

Code:
<?php
/* PHP goes here */
?>               
<!-- HTML goes here -->
<?php
/* More PHP goes here */
?>
Will.Spencer is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-13-2006, 08:21 PM   #5
Junior Member
 
Join Date: Nov 2006
Posts: 28
Rep Power: 0 peeling is on a distinguished road
Hi Will,

Thank you for the answers. I did some digging on my own and seems you can use fopen in PHP to generate static HTML pages from database queries. I won't post links to the code here, but you can do a google search for "static html pages using fopen". And don't ask me how I ended up there. I can understand a bit of PHP, but I can't write my own code.

I have been playing round with it for a few hours and finally got it working. Works real good. I needed to set up a cron job to refresh the html pages, but I guess it's worth it.
peeling is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 11-13-2006, 08:56 PM   #6
Distinguished Member
 
Join Date: Jul 2005
Posts: 2,208
Rep Power: 6 Will.Spencer is on a distinguished road
fopen() makes sense. I've always just closed the PHP tag, used some HTML, and opened a new PHP tag.

I'm not much of a PHP coder, but fopen() comes from C.
Will.Spencer is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-05-2006, 05:22 AM   #7
Junior Member
 
Join Date: Nov 2006
Posts: 6
Rep Power: 0 gemini181 is on a distinguished road
Quote:
Originally Posted by Will.Spencer View Post
You can call PHP from within HTML pages.

You have to configure httpd.conf to tell Apache to look for PHP in files with the .html extension.

This is done with an AddType declaration:

Code:
    AddType application/x-httpd-php .shtml
...
I need to experiment with this on shared hosting. Do you know if most 'standard' Unix servers are already configured this way?

Thank you.
gemini181 is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Old 12-05-2006, 05:57 AM   #8
Distinguished Member
 
Join Date: Jul 2005
Posts: 2,208
Rep Power: 6 Will.Spencer is on a distinguished road
Quote:
Originally Posted by gemini181 View Post
I need to experiment with this on shared hosting. Do you know if most 'standard' Unix servers are already configured this way?
Most that I have seen use .html, I'm one of the few people using the .shtml extension.

Code:
AddType application/x-httpd-php .shtml
Will.Spencer is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Intoruction - Basic HTML crafterz Tutorials and How-To... 8 10-25-2006 09:51 PM
Keeping several 404 pages for a short while stoli_sambuca Web Design and Development 7 09-12-2006 09:27 PM
CSS: Generate a CSS layout for your site OulZac Web Design and Development 7 07-06-2006 05:33 PM
Slicing to HTML parag2006 Web Design and Development 2 06-15-2006 11:19 AM
Changing a web site from HTML to ASP bluent Web Design and Development 1 11-14-2005 06:17 AM



All times are GMT -5. The time now is 10:31 PM.

Powered by vBulletin Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC5