Building Dynamic Sites using PHP

First I'm a network administrator and php developer. Not a writer.

Now, Here is the tech...

First Let talk a little about PHP

What is PHP? ..
Taken from http://php.net/manual/preface.php

"PHP, which stands for "PHP: Hypertext Preprocessor", is an
HTML-embedded scripting language. Much of its syntax is borrowed from C,
Java and Perl with a couple of unique PHP-specific features thrown in.
The goal of the language is to allow web developers to write
dynamically generated pages quickly"

What is MySQL?
Taken from
http://www.mysql.com/documentation/mysql/commented/manual.php?section=Introduction

MySQL is a very fast, multi-threaded, multi-user, and robust SQL
(Structured Query Language) database server. 

MySQL is free software. It is licensed with the GNU GENERAL PUBLIC LICENSE 

Now lets start coding a little ...

Script Output


        
<?php

// Defining Variables

define("DATABASE_HOST", "localhost using define()");

$DB_HOST = "localhost using $dbhost";

print
"<P>";
print
DATABASE_HOST;

print
"<P>";
print
$DB_HOST;

print
"<P>";


// Creating Arrays


$c = array(1.0,1.2,1.3);

print
$c[0];

$e = array(
"Linux"=>array("Slackware","Redhat","Corel"),
"Scripting"=>array("PHP","Perl","TCL")
);

$site_data = array(
"Linux Links"=>array("Slackware" => "www.slackware.com ","Redhat" => "www.redhat.com","Corel" =>
"www.corel.com"),
"Scripting Links"=>array("PHP" => "www.php.net ","PERL" => "www.perl.com","Python" =>
"www.python.org")
);


while(list(
$key, $value) = each($site_data["Linux Links"])) {
print
"<LI><A HREF=http://".$value.">".$key."</A>\n";
}
print
"<P>";


// Accessing an array

for($i=0; $i < count($c); $i++) {
print
$c[$i]."<br>\n";
}


print
"<p>\n";

// Array e
print($e["Linux"][0]);

print
"<p>\n";

for(
$i=0; $i<count($e["Scripting"]); $i++) {
print(
$e["Linux"][$i])." | \n";
print(
$e["Scripting"][$i])."<br>\n";
}

print
"<p>";

$link_array= array(
"Freshmeat" => "http://www.freshmeat.net/",
"PHPBuilder" => "http://phpbuilder.com/");

while(list(
$key, $value) = each($link_array)) {
print
"<LI><A HREF=".$value.">".$key."</A>\n";
}
print
"<P>";


$list_array= array(
"PHP Coding",
"PHP Development",
"PHP Classes");

for(
$i=0; $i < count($list_array); $i++) {
print
"<LI>$list_array[$i]\n";
}



// Creating functions


/*
** Function: linkArray()
** Input: array of links
** Output: Std HTML
** Description: Disply HTML links
**
**
*/

function linkArray($link_array)
{
while(list(
$key, $value) = each($link_array)) {
print
"<LI><A HREF=".$value.">".$key."</A>\n";
}
}

linkArray($link_array);
print
"<p>";


?>

PCCS-Linux.COM ::ource Advocate Articles catalogue
2000 2002