Saturday, August 7, 2010

Header

if (!defined('WEB_ROOT')) {
    exit;
}

// set the default page title
$pageTitle = 'My Online Shop';

// if a product id is set add the product name
// to the page title but if the product id is not
// present check if a category id exist in the query string
// and add the category name to the page title
if (isset($_GET['p']) && (int)$_GET['p'] > 0) {
    $pdId = (int)$_GET['p'];
    $sql = "SELECT pd_name
            FROM tbl_product
            WHERE pd_id = $pdId";
   
    $result    = dbQuery($sql);
    $row       = dbFetchAssoc($result);
    $pageTitle = $row['pd_name'];
   
} else if (isset($_GET['c']) && (int)$_GET['c'] > 0) {
    $catId = (int)$_GET['c'];
    $sql = "SELECT cat_name
            FROM tbl_category
            WHERE cat_id = $catId";

    $result    = dbQuery($sql);
    $row       = dbFetchAssoc($result);
    $pageTitle = $row['cat_name'];
}
?>



<?php echo $pageTitle; ?>




Footer

if (!defined('WEB_ROOT')) {
    exit;
}
?>


     

   ©

   Address :

    Phone :

    Email :

  

  

Thursday, August 5, 2010

Dynamic Websites Creation

PHP is probably the most popular web scripting language used today. PHP is popular because it's easy to learn and use - generally PHP makes life more exciting. Now that I’ve said that, I guess I should actually give you a reason or two to learn PHP!
  1. You will be able to do all kinds of neat things like process HTML forms, send mail from a web page, talk to a database et cetera.
  2. You will become a much more valuable person! Besides your web design skills, you will now have what is called ‘server-side programming’ skills – in this case, knowing PHP.
As depressing as it may seem, programmers usually are higher up on the totem pole. In other words, knowing how to program will put you in a higher bracket than people who only know web design.

php introduction

PHP is an open-source embeddable server-side language which is simple enough to use on small sites yet powerful enough to handle large, complex applications. This course is designed to provide students with a basic working knowledge of PHP.

Through reading assignments and lessons, it will acquaint students with the structure and foundations of the language, including variables, arrays, flow control, functions and form validation. Weekly exercises tie these concepts to practical applications.

This course takes an integrated approach to PHP, tying it to its (X)HTML and CSS environment so that students finish with a recognition of PHP's place in the overall process of web development.

Objectives for this class are to:
  • Learn foundations of PHP programming and security
  • Become familiar with 6 basic PHP data types
  • Learn basic flow control structures
  • Create and use functions and includes
  • Learn simple and deep form validation
  • Learn to construct sticky forms

Tuesday, August 3, 2010

PHP Calendar Functions

PHP Calendar Introduction

The calendar functions are useful when working with different calendar formats. The standard it is based on is the Julian day count (Julian day count is a count of days starting from January 1, 4713 B.C.). Note that the Julian day count is not the same as the Julian calendar!
Note: To convert between calendar formats, you must first convert to Julian day count, then to the calendar format.

Installation

The windows version of PHP has built-in support for the calendar extension. So, the calendar functions will work automatically.
However, if you are running the Linux version of PHP, you will have to compile PHP with --enable-calendar to get the calendar functions to work.

PHP Calendar Functions

PHP: indicates the earliest version of PHP that supports the function.
Function Description PHP
cal_days_in_month() Returns the number of days in a month for a specified year and calendar 4
cal_from_jd() Converts a Julian day count into a date of a specified calendar 4
cal_info() Returns information about a given calendar 4
cal_to_jd() Converts a date to Julian day count 4
easter_date() Returns the Unix timestamp for midnight on Easter of a specified year 3
easter_days() Returns the number of days after March 21, on which Easter falls for a specified year 3
FrenchToJD() Converts a French Republican date to a Julian day count 3
GregorianToJD() Converts a Gregorian date to a Julian day count 3
JDDayOfWeek() Returns the day of a week 3
JDMonthName() Returns a month name 3
JDToFrench() Converts a Julian day count to a French Republican date 3
JDToGregorian() Converts a Julian day count to a Gregorian date 3
jdtojewish() Converts a Julian day count to a Jewish date 3
JDToJulian() Converts a Julian day count to a Julian date 3
jdtounix() Converts a Julian day count to a Unix timestamp 4
JewishToJD() Converts a Jewish date to a Julian day count 3
JulianToJD() Converts a Julian date to a Julian day count 3
unixtojd() Converts a Unix timestamp to a Julian day count 4

PHP Array Functions

PHP Array Introduction

The array functions allow you to manipulate arrays.
PHP supports both simple and multi-dimensional arrays. There are also specific functions for populating arrays from database queries.

Installation

The array functions are part of the PHP core. There is no installation needed to use these functions.

PHP Array Functions

PHP: indicates the earliest version of PHP that supports the function.
Function Description PHP
array() Creates an array 3
array_change_key_case() Returns an array with all keys in lowercase or uppercase 4
array_chunk() Splits an array into chunks of arrays 4
array_combine() Creates an array by using one array for keys and another for its values 5
array_count_values() Returns an array with the number of occurrences for each value 4
array_diff() Compares array values, and returns the differences 4
array_diff_assoc() Compares array keys and values, and returns the differences 4
array_diff_key() Compares array keys, and returns the differences 5
array_diff_uassoc() Compares array keys and values, with an additional user-made function check, and returns the differences 5
array_diff_ukey() Compares array keys, with an additional user-made function check, and returns the differences 5
array_fill() Fills an array with values 4
array_filter() Filters elements of an array using a user-made function 4
array_flip() Exchanges all keys with their associated values in an array 4
array_intersect() Compares array values, and returns the matches 4
array_intersect_assoc() Compares array keys and values, and returns the matches 4
array_intersect_key() Compares array keys, and returns the matches 5
array_intersect_uassoc() Compares array keys and values, with an additional user-made function check, and returns the matches 5
array_intersect_ukey() Compares array keys, with an additional user-made function check, and returns the matches 5
array_key_exists() Checks if the specified key exists in the array 4
array_keys() Returns all the keys of an array 4
array_map() Sends each value of an array to a user-made function, which returns new values 4
array_merge() Merges one or more arrays into one array 4
array_merge_recursive() Merges one or more arrays into one array 4
array_multisort() Sorts multiple or multi-dimensional arrays 4
array_pad() Inserts a specified number of items, with a specified value, to an array 4
array_pop() Deletes the last element of an array 4
array_product() Calculates the product of the values in an array 5
array_push() Inserts one or more elements to the end of an array 4
array_rand() Returns one or more random keys from an array 4
array_reduce() Returns an array as a string, using a user-defined function 4
array_reverse() Returns an array in the reverse order 4
array_search() Searches an array for a given value and returns the key 4
array_shift() Removes the first element from an array, and returns the value of the removed element 4
array_slice() Returns selected parts of an array 4
array_splice() Removes and replaces specified elements of an array 4
array_sum() Returns the sum of the values in an array 4
array_udiff() Compares array values in a user-made function and returns an array 5
array_udiff_assoc() Compares array keys, and compares array values in a user-made function, and returns an array 5
array_udiff_uassoc() Compares array keys and array values in user-made functions, and returns an array 5
array_uintersect() Compares array values in a user-made function and returns an array 5
array_uintersect_assoc() Compares array keys, and compares array values in a user-made function, and returns an array 5
array_uintersect_uassoc() Compares array keys and array values in user-made functions, and returns an array 5
array_unique() Removes duplicate values from an array 4
array_unshift() Adds one or more elements to the beginning of an array 4
array_values() Returns all the values of an array 4
array_walk() Applies a user function to every member of an array 3
array_walk_recursive() Applies a user function recursively to every member of an array 5
arsort() Sorts an array in reverse order and maintain index association 3
asort() Sorts an array and maintain index association 3
compact() Create array containing variables and their values 4
count() Counts elements in an array, or properties in an object 3
current() Returns the current element in an array 3
each() Returns the current key and value pair from an array 3
end() Sets the internal pointer of an array to its last element 3
extract() Imports variables into the current symbol table from an array 3
in_array() Checks if a specified value exists in an array 4
key() Fetches a key from an array 3
krsort() Sorts an array by key in reverse order 3
ksort() Sorts an array by key 3
list() Assigns variables as if they were an array 3
natcasesort() Sorts an array using a case insensitive "natural order" algorithm 4
natsort() Sorts an array using a "natural order" algorithm 4
next() Advance the internal array pointer of an array 3
pos() Alias of current() 3
prev() Rewinds the internal array pointer 3
range() Creates an array containing a range of elements 3
reset() Sets the internal pointer of an array to its first element 3
rsort() Sorts an array in reverse order 3
shuffle() Shuffles an array 3
sizeof() Alias of count() 3
sort() Sorts an array 3
uasort() Sorts an array with a user-defined function and maintain index association 3
uksort() Sorts an array by keys using a user-defined function 3
usort() Sorts an array by values using a user-defined function 3

Saturday, July 31, 2010

Variables

Variables in PHP are represented by a dollar sign followed by the name of the variable. The variable name is case-sensitive.
Variable names follow the same rules as other labels in PHP. A valid variable name starts with a letter or underscore, followed by any number of letters, numbers, or underscores. As a regular expression, it would be expressed thus: '[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*'
Note: For our purposes here, a letter is a-z, A-Z, and the bytes from 127 through 255 (0x7f-0xff).
Note: $this is a special variable that can't be assigned.
Tip
See also the Userland Naming Guide.
For information on variable related functions, see the Variable Functions Reference.
$var 'Bob';$Var 'Joe';
echo 
"$var$Var";      // outputs "Bob, Joe"
$4site 'not yet';     // invalid; starts with a number$_4site 'not yet';    // valid; starts with an underscore$täyte 'mansikka';    // valid; 'ä' is (Extended) ASCII 228.?>
By default, variables are always assigned by value. That is to say, when you assign an expression to a variable, the entire value of the original expression is copied into the destination variable. This means, for instance, that after assigning one variable's value to another, changing one of those variables will have no effect on the other. For more information on this kind of assignment, see the chapter on Expressions.
PHP also offers another way to assign values to variables: assign by reference. This means that the new variable simply references (in other words, "becomes an alias for" or "points to") the original variable. Changes to the new variable affect the original, and vice versa.
To assign by reference, simply prepend an ampersand (&) to the beginning of the variable which is being assigned (the source variable). For instance, the following code snippet outputs 'My name is Bob' twice:
$foo 'Bob';              // Assign the value 'Bob' to $foo$bar = &$foo;              // Reference $foo via $bar.$bar "My name is $bar";  // Alter $bar...echo $bar;
echo 
$foo;                 // $foo is altered too.?>