lahat na sa wma4
PHP
is a recursive acronym for “_____: Hypertext Preprocessor”
PHP
It is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML.
PHP
-is a server-side scripting language
-scripts are executed on the server
-supports many databases (MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, Generic ODBC, etc.)
-is open source software
-is free to download and use
PHP
-runs on different platforms (Windows, Linux, Unix, etc.)
-is compatible with almost all servers used today (Apache, IIS, etc.) >
-is FREE to download from the official PHP resource: www.php.net >
-is easy to learn and runs efficiently on the server side
MySQL
is a database server
is ideal for both small and large applications
supports standard SQL
compiles on a number of platforms
is free to download and use
<?php and ?>
The PHP code is enclosed in special start and end processing instructions
server
PHP code is executed on the?
PHP echo() statement.
This program is extremely simple and you really did not need to use PHP to create a page like this. All it does is display: Hello World using the?
//
In PHP, we use ____ to make a single-line comment
/* “comment inside” *
In PHP, we use ____ to make a large comment
Variables
are used for storing values, like text strings, numbers or arrays.
$
All variables in PHP start with a ___ sign symbol
The concatenation operator (.)
is used to put two string values together.
1. Arithmetic
2. Assignment
3. Comparison
4. Logical
There are four classifications of operators:
if statement
use this statement to execute some code only if a specified condition is true
if…else statement
use this statement to execute some code if a condition is true and another code if the condition is false
if...elseif....else statement
use this statement to select one of several blocks of code to be executed
switch statement
use this statement to select one of many blocks of code to be executed
curly braces { }
If more than one line should be executed if a condition is true/false, the lines should be enclosed within?
break
Use _______ to prevent the code from running into the next case automatically.
array variable
is a storage area holding a number or text.
array
is a special variable, which can store multiple values in one single variable.
Numeric array
Associative array
Multidimensional array
In PHP, there are three kind of arrays:
Numeric array
An array with a numeric index
Associative array
An array where each ID key is associated with a value
Multidimensional array
An array containing one or more arrays
numeric array
stores each array element with a numeric index.
associative array
each ID key is associated with a value.
multidimensional array
each element in the main array can also be an array.
loops
Often when you write code, you want the same block of code to run over and over again in a row. Instead of adding several almost equal lines in a script we can use?
while loop
loops through a block of code while a specified condition is true
do...while loop
loops through a block of code once, and then repeats the loop as long as a specified condition is true
for loop
loops through a block of code a specified number of times
foreach
loops through a block of code for each element in an array
init
condition
increment
PHP Loops - For Parameters (3):
init
Mostly used to set a counter (but can be any code to be executed once at the beginning of the loop)
condition
Evaluated for each loop iteration. If it evaluates to TRUE, the loop continues. If it evaluates to FALSE, the loop ends.
increment
Mostly used to increment a counter (but can be any code to be executed at the end of the loop)
function (parang method sa java ata i2 eh)
To keep the script from being executed when the page loads, you can put it into a
function
will be executed by a call to the function.
parameters
To add more functionality to a function, we can add
$_GET function
is used to collect values from a form sent with method="get".
$_POST function
is used to collect values from a form sent with method="post".
8
However, there is an ___ Mb max size for the POST method, by default (can be changed by setting the post_max_size in the php.ini file).
htmlspecialchars()
makes sure any characters that are special in html are properly encoded so people can't inject HTML tags or Javascript into your page.
POST
Information sent from a form with the _______ method is invisible to others and has no limits on the amount of information to send
MySQL
is a very popular, open source database.
MySQL
provides an interactive shell for creating tables, inserting data, etc.
\c
If you decide you don't want to execute a command that you are in the process of entering, cancel it by typing
SHOW
Use the _____ statement to find out which databases currently exist on the server
create database
To create a new database, issue the ____ _____ command:
use
§To the select a database, issue the “____” command
empty set
indicates that I have not created any tables yet.
show tables;
Once you have selected a database, you can view all database tables using the what command?
VARCHAR
Is usually used to store string data.
CREATE TABLE
To create a table, use the _______ ______ command:
show tables;
To verify that the table has been created:
DESCRIBE
To view a table structure, use the ___________ command:
DROP TABLE
To delete an entire table, use the ______ _____ command:
INSERT
Use the ________ statement to enter data into a table.
SELECT
The _______ statement is used to pull information from a table.
SELECT
The simplest form of _______ retrieves everything from a table
ORDER BY
To sort a result, use an _____ ___ clause.
DESC
To sort in reverse order, add the ?
NULL
means missing value or unknown value.
LIKE , NOT LIKE
To perform pattern matching, use the ____ or ____ _____ comparison operators
_
Used to match any single character.
%
Used to match an arbitrary number of characters.
Reg Ex Example
Reg Ex Example
COUNT()
The _____ function counts the number of non-NULL results.
Retrieving Data
Chances are your application will spend the majority of its efforts retrieving and formatting requested data
mysqli extension
also offers the ability to manage result sets using both associative and indexed arrays using the fetch_array() and fetch_row() methods.
fetch_array() method
is actually capable of retrieving each row of the result set as an associative array, a numerically indexed array.
fetch_array()
retrieves both arrays; you can modify this default behavior by passing one of the following values in as the result type.
MYSQLI_ASSOC
Returns the row as an associative array, with the key represented by the field name and the value by the field contents.
MYSQLI_NUM
Returns the row as a numerically indexed array, with the ordering determined by the ordering of the field names as specified within the query
INSERT INTO
is a statement that adds data to the specified MySQL database table
num_rows() method
is useful when you want to learn how many rows have been returned from a SELECT query statement