Skip Navigation

www.wimb.net - PHP / MySQL



On this page:

PHP

Normally when a Web browser looks up a URL the computer contacts the HTTP server with the URL. The HTTP server looks at the filename requested by the computer and then sends that file back. The browser then displays the file in the appropriate format.

However, it is possible to set up the HTTP server so that whenever a file of a specific type is requested that file is not sent back; instead it is executed as a program, and whatever that program outputs is sent back for your computer to display.

Is a server side language. It runs on the server and sends its output via Internet to the browser. This output is standard xhtml or anything you want. The example below gives the same output as the previous example2.html

Very simple php example:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html>
 <head>
 <title>simple document</title>
 </head>
 <body>
 <?php
   echo '<p>a simple paragraph</p>';
 ?>
 </body>
 </html>

Here is example8.php. If this file is on a webserver, with php then it outputs a the same as example 2. If the file is on a computer, or on a server without php, then the browser may show an empty screen, or ask you if the file should be downloaded. To see the real page the PHP file needs to be processed by a PHP interpreter.
When you have a local server running then you may call the file from the browser like: http://localhost/htmlintro/example8.php

There are several ways to use php in a web page. The above example is one of them. A common use is the intelligent including of menu section from one single file in different pages. When the menu file is modified, the result is visible in all pages.
Some other examples:

  • Page hit counter
  • File download counter
  • Intelligent 404 error page
  • Guest book, with text file or MySQL

PHP supports also many databases, like MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.) Making a page in PHP is something like writing a report in ABAP. First step is to collect data from a database, from ASCII files, or even from another website. Next is to process this data to make it ready to show it on the screen.

The official php site

For an introduction on PHP, please look at w3schools.

MySQL

MySQL is very strong in combination with php. Below is a small example program that counts file downloads. The name of this php program is "tel.php". It does not send any output to the browser, it only updates one record of the download table. It uses also a more or less standard SQL language

<?php
// filename: tel.php
// process the data from the input form
$url = $_SERVER['QUERY_STRING'];

if (empty($url))
{
$url = 'http://www.wimb.net/index.php'; // put also in database for counting
}
// echo $url;
include('_xYz/connect.php');
$sql = "UPDATE joblinks SET count=count+1 WHERE url = '$url'";
$result = mysql_query($sql);
// echo 'record is updated';
mysql_close();
echo '<meta http-equiv="refresh" content="0;url='.$url.'">';
exit();
?>

The official MySQL site

SQL can be learned at the w3schools.

For the fanatic readers, here is the relation between MySQL and SAP.

PID: 7014 CLT: 0.001 LMD: 2013-Aug-17

Updated 2007 Oct. 09