Web Coding & Development All-in-One For Dummies
Book image
Explore Book Buy On Amazon
It’s one thing to know about HTML and CSS and PHP and all the rest of web coding and development, but it’s quite another to actually do something useful with these technologies. A dynamic web page is one that includes content that, rather than being hard-wired into the page, is generated on-the-fly from the web server. This means the page content can change based on a request by the user, by data being added to or modified on the server, or in response to some event, such as the clicking of a button or link.

It likely sounds a bit like voodoo to you now, so perhaps a bit more detail is in order. For example, suppose you want to use a web page to display some data that resides on the server. Here’s a general look at the steps involved in that process:

  1. JavaScript determines the data that it needs from the server.

    JavaScript has various ways it can do this, such as extracting the information from the URL, reading an item the user has selected from a list, or responding to a click from the user.

  2. JavaScript sends a request for that data to the server.

    In most cases, JavaScript sends this request by calling a PHP script on the server.

  3. The PHP script receives the request and passes it along to MySQL.

    The PHP script uses the information obtained from JavaScript to create an SQL command that MySQL can understand.

  4. MySQL uses the SQL command to extract the required information from the database and then return that data to the PHP script.
  5. The PHP script manipulates the returned MySQL data into a form that JavaScript can use.

    JavaScript can’t read raw MySQL data, so one of PHP’s most important tasks is to convert that data into a format called JavaScript Object Notation (JSON, for short, and pronounced like the name Jason) that JavaScript is on friendly terms with.

  6. PHP sends the JSON data back to JavaScript.
  7. JavaScript displays the data on the web page.

    One of the joys of JavaScript is that you get tremendous control over how you display the data to the user. Through existing HTML and CSS, and by manipulating these and other web page elements using JavaScript, you can show your data in the best possible light.

About This Article

This article is from the book:

About the book author:

Paul McFedries is a true renaissance geek. He has been a programmer, consultant, database developer, and website builder. He's also the author of more than 90 books including top sellers covering Windows, Office, and macOS.

This article can be found in the category: