Online Manual

PHP
Chapter 17

What is PHP?
PHP (Hypertext Preprocessor) is a server-side HTML embedded scripting language that was developed in C and is designed especially for working with relational database systems.

How do I set up a PHP Program?
A PHP program is embedded directly in the HTML document. It must have a .php3 extension in order for the server to look for PHP code in the document. Here is how you embed the PHP:
 

     <?
     insert PHP code here
     ?>

To merely display the information in your database without the use of a form to call a php script you simply create your HTML document as you would any other web page but instead of the extension of .htm or .html you need to name the file with the extension .php3. Then within the document itself the section that you'd like to be the PHP code, you begin it with <? and end it with ?>. For instance:          

These are the products I sell:

<TABLE BORDER="0"> <? mysql_connect(localhost, username, password); $result = mysql(mydatabase, "select * from products"); $num = mysql_numrows($result); $i = 0; while($i < $num) { echo "<TR>n"; echo "<TD>n"; echo mysql_result($result,$i,"prodid"); echo "</TD>n<TD>"; echo mysql_result($result,$i,"name"); echo "</TD>n<TD>"; echo mysql_result($result,$i,"price"); echo "</TD>n"; echo "</TR>n"; $i++;} ?> </TABLE>

For detailed information regarding PHP, you can go to their online manual: http://www.php.net/manual

Other useful sites include:

http://www.vtwebwizard.com/tutorials/mysql/

http://www.devshed.com/Server_Side/PHP/Introduction/


[HOME]