0% found this document useful (0 votes)
145 views

PHP MySQL

The document provides instructions for installing a LAMP stack on Windows using WAMP server. It explains how to download and install WAMP server, find the document root, configure PHP, access phpinfo and phpMyAdmin, and includes some basic PHP coding examples using variables, loops, and if/switch statements.

Uploaded by

lan cruzz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
145 views

PHP MySQL

The document provides instructions for installing a LAMP stack on Windows using WAMP server. It explains how to download and install WAMP server, find the document root, configure PHP, access phpinfo and phpMyAdmin, and includes some basic PHP coding examples using variables, loops, and if/switch statements.

Uploaded by

lan cruzz
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 28

Installation Requirement:

Web Server (Apache)

PHP (version 5.x)

Database (MySQL 5.x)

Text Editor (Notepad++)

Web Browser (Firefox)

“The Stack”: LAMP, MAMP, WAMP, XAMP

Linux, Mac, Win, X=any

Apache

MySQL

PHP

php.net/manual/en/

Start:
1. Download @ www.wampserver.com
2. Download @ notepad-plus-plus.org
3. Install all Microsoft Visual C++ Redistribution 2008-2017 (if necessary)
4. Install and run WAMP – select browser and text editor.

Find the document root


Create folder exercise_files
Configure PHP

Go to Localhost
Homepage
Tools  PHP Info()
Ctrl+F  search php.ini

Or
Ctrl+F  search error reporting
Devp & Prod environment

On  Off
Search output buffer
Change 4096 (prod) to off (devp)

Search  timezone
http://www.php.net/manual/en/timezones.asia.php
Copy paste change UTC to Asia/Kuala_Lumpur
Save setting

Restart WAMP Server


Review changes

Go to php info
Go to localhost  phpmyadmin
To set DB only to MySQL (save memory used)

Login
Root

GO

Change password
Text Editor

Open Notepad++
Save at root directory
Embedding PHP Code on a Page

<?php … ?>

Eg:

<?php phpinfo(); ?>

To view source

In Firefox, click Alt button to get menu bar

Then go to Tool menu


Trail

Database

Browser  Apache Server  Find File  Run php file  convert to HTML  Show on Browser
PHP

php.net/docs.net

Data Types

Variable

 Start with a $ sign, eg: $item, $My_Item


 Case sensitive
Loops

1. While loops
2. For loops
3. Foreach loops
4. Continue
5. Break
6. Understanding array pointers
Exercise Day 2

1. Using foreach loop, print this array in order e.g

4
8
23
42
15
16

2. Using loop, show sifir 12 e.g

1 x 12 = 12
.
.
12 x 12 = 144

3. Change this case statement to IF statement

//ChineseZodiac

$year = 2018;

Switch (($year – 4) % 12) {

case 0: $zodiac = ‘Rat’; break;


case 1: $zodiac = ‘Ox’; break;
case 2: $zodiac = ‘Tiger’; break;
case 3: $zodiac = ‘Rabbit’; break;
case 4: $zodiac = ‘Dragon’; break;
case 5: $zodiac = ‘Snake’; break;
case 6: $zodiac = ‘Horse’; break;
case 7: $zodiac = ‘Goat’; break;
case 8: $zodiac = ‘Monkey’; break;
case 9: $zodiac = ‘Rooster’; break;
case 10: $zodiac = ‘Dog’; break;
case 11: $zodiac = ‘Pig’; break;

}
echo “{$year} is the year of the {zodiac}.<br />;
4. Change this IF statement to switch case
$a = 3;
$b = 4;

If ($a > $b) {


echo “a is larger than b”;
} elseif ($a < $b) {
echo “a is smaller than b”;
} else {
echo “a is equal to b”;
}

You might also like