First of all, I create a file called "test.php". On the first line of "test.php", I input php code following:
Next step is to create HTML tags and Body tags. Inside body tags, I create a form that details:
form name="calculation" method="post" action="test.php"
In the form, I have a table with its details
After the form close with /form, I state $result as a result of the mathematical formula when we interact with add, subtract, multiply and divide.
Now, the process of coding is finished, time to test code function.
I assign number 50 to value 1 and number 5 to value 2 then test functions of add, subtract, multiply and divide on firefox web browser.
Each of illustrated images below will show different mathematical formula.
Monday, 25 May 2009
PHP Operators
There are different types of PHP Operators:
Result :
ARITHMETIC OPERATORS:
simply perform basic mathematical tasks
Practical Example :
Results:
COMPARISON OPERATORS
$a = 60; $b = 50;
// using (\$) to print a vairable with its dollar sign.
echo "Original number is: $a of \$a and $b of \$b ";
// == "is equal to"
if ($a == $b)
{ echo "TEST 1: \$a equals to \$b
"; } else {
echo "TEST 1: \$a does not equal to \$b
"; } // != "is not equal to" if ($a != $b) { echo "TEST 2: \$a does not equal to \$b
"; } else { echo "TEST 2: \$a equals to \$b
"; } //Greater than if ($a > $b) { echo "TEST 3: \$a is greater than \$b
"; } else { echo "TEST 3: \$a is not greater than \$b
"; } // Less than if ($a < $b) { echo "TEST 4: \$a is less than \$b
"; } else { echo "TEST 4: \$a is not less than \$b
"; } //Greater or equal to if ($a >= $b) { echo "TEST 5: \$a is Greater or equal to \$b
"; } else { echo "TEST 5: \$a is not Greater or equal to \$b
"; } // Less than or equal to if ($a <= $b) { echo "TEST 6: \$a is less or equal to \$b
"; } else { echo "TEST 6: \$a is not less or equal to \$b
"; } ?>
My results is shown on web browser:
LOGICAL OPERATORS
Allow our script to determine the status of conditions. In the context of if...else or while statements, it executes certain code based on which conditions are true and which are false.
At the moment, I have try my practical samples on && (and) and || (or) operators to determine the validity of a few comparisons.
My result on Firefox browser:
- Assignment Operators: assign values to variables and can also add to or subtract from a variable's current value.
- Arithmetic Operators: addition, subtraction, division and multiplication occur when these operators are used.
- Comparison Operators: compare 2 values and return either TRUE or FALSE.
- Logical Operators: determine the status of conditions.
- += "changes the values of a variable to current value plus the value on the right side".
- eg: $a +=3;
- -= "changes the value of a variable to the current value minus the value on the right side"
- eg: $a -=3;
- .= "concatenates (adds on to) the value on the right side with the current value".
- eg: $a .= "string";
Result :
ARITHMETIC OPERATORS:
simply perform basic mathematical tasks
- + "Adds values"
- - "Subtracts values"
- * "Multiplies values"
- / "Divides values"
- % "Returns the modulus or remainder".
Practical Example :
Results:
COMPARISON OPERATORS
- == " Equal to"
- != "Not equal to"
- > "Greater than"
- < "Less than"
- >= "Greater than or equal to"
- <= "Less than or equal to"
$a = 60; $b = 50;
// using (\$) to print a vairable with its dollar sign.
echo "Original number is: $a of \$a and $b of \$b ";
// == "is equal to"
if ($a == $b)
{ echo "TEST 1: \$a equals to \$b
"; } else {
echo "TEST 1: \$a does not equal to \$b
"; } // != "is not equal to" if ($a != $b) { echo "TEST 2: \$a does not equal to \$b
"; } else { echo "TEST 2: \$a equals to \$b
"; } //Greater than if ($a > $b) { echo "TEST 3: \$a is greater than \$b
"; } else { echo "TEST 3: \$a is not greater than \$b
"; } // Less than if ($a < $b) { echo "TEST 4: \$a is less than \$b
"; } else { echo "TEST 4: \$a is not less than \$b
"; } //Greater or equal to if ($a >= $b) { echo "TEST 5: \$a is Greater or equal to \$b
"; } else { echo "TEST 5: \$a is not Greater or equal to \$b
"; } // Less than or equal to if ($a <= $b) { echo "TEST 6: \$a is less or equal to \$b
"; } else { echo "TEST 6: \$a is not less or equal to \$b
"; } ?>
My results is shown on web browser:
LOGICAL OPERATORS
Allow our script to determine the status of conditions. In the context of if...else or while statements, it executes certain code based on which conditions are true and which are false.
At the moment, I have try my practical samples on && (and) and || (or) operators to determine the validity of a few comparisons.
My result on Firefox browser:
PHP Variable and Value Types
Variable is a representation of a particular value, such as blue or 1234.
Notice: To create a variable, we should remember these steps:
Variable names can be recognized by:
and result
Notice: To create a variable, we should remember these steps:
- Thinking of a good name
- Putting a dollar sign ($) in front of the name.
- Using equals sign (=) after the name to assign a literal value to that variable and put the value in quotation marks.
- Assigning the value to a variable is an instruction and should be terminated with a semicolon (;).
Variable names can be recognized by:
- They begin with a dollar sign ($)
- can not begin with a numeric character
- can contain numbers and the underscore (_) character
- they are case sensitive.
- Scalar variables contain 1 value at a time
- Array contains a list of values or even another array.
- Integer: whole number (without decimals)
- Floating point numbers ("float" or "double"): number with decimals
- String: text or numeric information, specified within double quotes (" ") or single quote (' ').
and result
Instruction terminator, Error displayed by PHP Parser
The instruction terminator is known as the semicolon (;), is definitely required at the end of each commands. It will tells PHP parser:"this command is done, lets move on to next command".
If we do not end commands with the semicolon, the PHP Parser will confuse and show error to us.
My practices below illustrate popular problems in php coding and their fixing method.
firstly, I get a error with semicolon. there are 2 lines, one ends with semicolon, another does not. By PHP Syntax checking function from PHP Designer, I got a warning message with highlighted pink color.
In web browser preview, the PHP Parser shows me an error message.
On line number 2, I input a semicolon at the end of the command.
the error is gone now and the fixing method is finished.
Besides that, another problem can occur during coding process is quotation marks. When we use quotation marks inside other quotation marks, the inner pair must be delineated from the outside pair using the escape (\) character (also known as a backslash).
In my practice, a pink highlighted line which has a word COOL inside (" "), a warning error is marked on the left side of php designer.
On the broswer, I also have a warning message.
The error cause the problem is a set of quotation marks within another set of quotation marks.
I have a simple fix on line number 5:
echo"PHP is really \"COOL\"";
A result after fixing:
On the other hand, I also replace quotation marks ("") with (''). the code will be:
echo"PHP is really 'COOL' ";
A result will appear :
If we do not end commands with the semicolon, the PHP Parser will confuse and show error to us.
My practices below illustrate popular problems in php coding and their fixing method.
firstly, I get a error with semicolon. there are 2 lines, one ends with semicolon, another does not. By PHP Syntax checking function from PHP Designer, I got a warning message with highlighted pink color.
In web browser preview, the PHP Parser shows me an error message.
On line number 2, I input a semicolon at the end of the command.
the error is gone now and the fixing method is finished.
Besides that, another problem can occur during coding process is quotation marks. When we use quotation marks inside other quotation marks, the inner pair must be delineated from the outside pair using the escape (\) character (also known as a backslash).
In my practice, a pink highlighted line which has a word COOL inside (" "), a warning error is marked on the left side of php designer.
On the broswer, I also have a warning message.
The error cause the problem is a set of quotation marks within another set of quotation marks.
I have a simple fix on line number 5:
echo"PHP is really \"COOL\"";
A result after fixing:
On the other hand, I also replace quotation marks ("") with (''). the code will be:
echo"PHP is really 'COOL' ";
A result will appear :
My first study in PHP programming language.
XAMPP - A package of PHP, MySQL and Apache server
XAMPP is a cross platform web server package, which is free and open source, consists of Appche HTTP Server, MySQL Database, PHPMyAdmin and is written in the php programming language.
XAMPP is an acronym for:
Setup illustration:
After double click a package installer, I will a window like this:
Next step is to choose installed location path for XAMPP package.
After a complete process, there is a dialog box which lets me know the installation is successfully finished and ask me to open the Web server control panel.
The control panel of web server package will have an interface like this:
now , I try to test a local web server working or not by entering "localhost" on URL address bar. if it works, it will show XAMPP Layout like :
XAMPP is an acronym for:
- X (meaning cross-platform)
- Apache HTTP Server
- MySQL
- PHP
- Perl
XAMPP is available for Microsoft Windows, Linux, Solaris, and Mac OS X, and is mainly used for web development projects.
Download the package from http://www.apachefriends.org/en/xampp-windows.htmlSetup illustration:
After double click a package installer, I will a window like this:
Next step is to choose installed location path for XAMPP package.
After a complete process, there is a dialog box which lets me know the installation is successfully finished and ask me to open the Web server control panel.
The control panel of web server package will have an interface like this:
now , I try to test a local web server working or not by entering "localhost" on URL address bar. if it works, it will show XAMPP Layout like :
Monday, 4 May 2009
Initial Database Design
At the moment, I have collected all data supported from the client, I also search all possible sub-categories that should be displayed when I am searching layout design on other ecommerce supermarket online
From these, I have got a initial database:
the database will be updated when me and my client have finished discussion.
For example: I think I should have a table called tax so that the shop owner is able to change the tax for different years, after changing, every product in shopping cart will be plus with new tax.
From these, I have got a initial database:
the database will be updated when me and my client have finished discussion.
For example: I think I should have a table called tax so that the shop owner is able to change the tax for different years, after changing, every product in shopping cart will be plus with new tax.
Comparison among Ecommerce Websites and Initial Design
I have researched on some ecommerce websites so far, each of them give me a hint to design my template.
http://www.lauraashley.com/
Laura Ashley has simple layout but nice, it has a balance of usability and has a font page for customer visits. I like this idea either, but its adverts are relevant to flash design which slows down page loading.
The navigation menu and search menu are on the same line, this idea will be applied to my design. I also like presentation of template, which has space between font ground of template and its background., makes me feel the website tidy and clear.
http://www.asda.co.uk
Asda has simple layout and nice navigation but it is inconvenient to look for a chosen sub-category. In addition, the color is matching between green and white.
http://www.sainsburry.com
Sainsburry takes maximum size in web page and page is loading very slow.
http://www.tesco.com/
Tesco give a bored layout for customer, but effective navigation which is linking to different sub-categories.
From hint collections that I have learned from the websites, I have got a initial website layout for my project.
http://www.lauraashley.com/
Laura Ashley has simple layout but nice, it has a balance of usability and has a font page for customer visits. I like this idea either, but its adverts are relevant to flash design which slows down page loading.
The navigation menu and search menu are on the same line, this idea will be applied to my design. I also like presentation of template, which has space between font ground of template and its background., makes me feel the website tidy and clear.
http://www.asda.co.uk
Asda has simple layout and nice navigation but it is inconvenient to look for a chosen sub-category. In addition, the color is matching between green and white.
http://www.sainsburry.com
Sainsburry takes maximum size in web page and page is loading very slow.
http://www.tesco.com/
Tesco give a bored layout for customer, but effective navigation which is linking to different sub-categories.
From hint collections that I have learned from the websites, I have got a initial website layout for my project.
Subscribe to:
Posts (Atom)