Account Manager
 

An Overview of PHP

What is PHP?

PHP is a server-side HTML embedded scripting language that was developed in C and is designed to work especially well with relational database systems. In fact, you can implement and maintain a MySQL database entirely with PHP.

In addition, PHP is an excellent way to embed scripting languages such as C, Java and Perl into your Web pages, and it is a very efficient way to implement advanced tasks such as database queries.

How do I set up a PHP Program?

A PHP program is embedded directly in the HTML document. It must have one of the following file extensions: .phtml .php .php4 .php3 or .phps.

Within the document itself the section containing the PHP code must begin and end with PHP tags — begin with <?php and end with ?>. <?php insert PHP code here ?>

How do I work with a MySQL database using PHP?

To merely display the information in your database without the use of a form to call a PHP script, create an HTML document as you would any other Web page but giving it one of the following file extensions: .phtml .php .php4 .php3 or .phps.

The following is an extended example:
<h1>These are the products I sell:</h1>
<table border="1">
<?php
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>

In the example above, putting the loop in the PHP program creates a table with the products listed. (NOTE—your username and password for the database are not written in the file when it's displayed on the Internet so users viewing the source of your Web page will not see your password.

PHP Resources

PHP Online Manualexternal link icon

Introduction to PHPexternal link icon

Zend Web Siteexternal link icon

DevShed on PHPexternal link icon

PHP Wizardexternal link icon

PHP Builderexternal link icon

PHP Resource Indexexternal link icon

HotScripts on PHPexternal link icon

PHP Code Exchangeexternal link icon



Was this answer helpful?

Add to Favourites Add to Favourites

Print this Article Print this Article


Powered by WHMCompleteSolution