Welcome to PCCS-Linux.COM Hello, and welcome to the PCCS-Linux Home Page.
Your last visit was !!!
Your Browser is running on Other
 
Variables
Your First PHP Script
<? echo "Hello World"; ?>

Creating Variables to use inside you scripts...
<?

// a is assigned a value of 1
$a = "1";

// b is assigned a value of 2
$b = "2";

// c is assigned the sum of a and b
$c = "$a + $b"; 

// today is assigned its value using the PHP date function
$today = date("M-d-Y");

// connected_from is assigned its value from GLOBAL variables
$connected_from = $GLOBALS["REMOTE_ADDR"];

?>

Getting GLOBAL variables
<? phpinfo() ?>

Creating arrays

From a SELECT box (array list1[])

<select multiple size="2" name="list1[]">


<?
$query = "
SELECT DISTINCT name
FROM software
WHERE category = 'ORGEXT'
ORDER BY name";
";
$appsres = mysqlquery("$db_name","$query")

for ($i = 0; $i < mysql_numrows($appsres); $i++):
        $appslist_output = mysql_result($appsres,$i,"name");
        echo "
";
endfor;
?>



To Process the list1[] array do something like;
Other arrarys
<?

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

$d = array("Monday"=>"Mon", ... ,"Sunday"=>"Sun");

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

for($i=0; $i < count($c); $i++) {
        print $c[$i];

// Array d
print $d[0];

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

?>

>> Comments/FeedBack


Page hits 69 last request on :12:37



This web site is prepared and maintained by Chauncey Thorn.
The information contained in this site was valid at the time of posting.
Chauncey Thorn, assumes no liability for damages incurred directly or indirectly as a result of errors, omissions or discrepancies.

Remember most of the content here are my notes...

All logos and trademarks in this site are property of their respective owner. All the rest © by PCCS-Linux.COM

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