What is it? In programming, static and dynamic are terms used to describe content. Static content is content that is preset and doesn't change. Dynamic content is the exact opposite; it changes. Static Example Code:
<font face="Georgia, serif">Welcome User</font>
Displays on page: quote: Welcome User
Dynamic Example (PHP) Code:
<? $user = "Entelligence"; ?> <font face="Georgia, serif">Welcome <? echo $user ?></font>
Displays on page: quote: Welcome Entelligence
Just note that it will display welcome and (whatever the value of $user is).
Why would I want to use dynamic content?
There are many reasons that you might want to use dynamic content. One of the biggest ones is for personalizing. It seems a lot nicer when you go to a site and it says "welcome (your name)", rather than just "welcome user". You could also use it to display local weather, news, etc. for users based on their zip code. Dynamic content can also make a site easier to maintain.
How Do I add dynamic content to my site?
A very common web programming language for displaying dynamic content is PHP. This is very simple example of how to do this in PHP (note that PHP must be installed on your web server): First, lets declare our variable $user in our header.
<html> <head> <title>PHP Example</title> <? $user = "Your Name Here"; ?> </head> <body> <font face="Georgia,serif">Welcome <? echo $user ?></font> </body> </html>
That's it. Of course this is a very basic example and probably wouldn't have much use over static code. But if we wanted to; we could make $user = $sqluser and make $sqluser = an sql query to get the username stored in a database.
feedback form
feedback form
by Entelligence edited by big greg  last modified: 2004-06-07 07:53:00 |