SlideShare a Scribd company logo
PHP AND MYSQL
Index
1. What is php?
2. Uses of php
3. Basic syntax of php
4. Variables
5. Echo/print statement
6. Array
7. Decision making
8. Loops
9. Functions
10. Mysql connections to php
11. Framework
What is php ?
 Php is scripting language commonly used on web servers.
 stands for Php: Hypertext preprocessor.
 open source.
 Embedded code.
 Multiple operating systems/web servers.
Uses of php
 Programming functions.
 You can add, delete, modify, etc within database through php.
 Encrypt data.
 Using PHP, you can restrict users to access some pages of your
website.
Basic php syntax
<html>
<head>
<title></title>
</head>
<body>
<?php
echo “Hello!PHP”; //prints Hello!PHP
?>
</body>
</html>
 Comment: To make the single line comment use //.To make large
comment block use /* and ends with */.
Example:
<?php
//this is comment
/*this is comment
Block*/
?>
Variables
 Php variables start with $ sign and followed by name of variable.
 Case sensitive($FOO!=$foo!=fOo)
 Globally and locally scoped variable
 Global variables can be placed anywhere.
 Local variables restricted to a function or class.
 Certain variables are reserved by php
 Form variables($_post,$_get)
 Server variables($_server),etc.
Variables usage
Example:
<?php
$txt = "Hello world!";
$x = 5;
$y = 5.44;
echo $txt; // prints Hello world!
echo ”br”;
echo $x; // prints 5
echo “br”;
echo $y; // prints 5.44
?>
Echo/Print
 There are two ways to print the output: echo and print
Example:
<?php
$foo = 25;
$bar = “Well come to php”;
echo $bar; //prints Well come to php
echo $foo; //prints 25
echo $foo,$bar; //prints 25hello
?>
Arrays
 An array is a special variable that stores more than one element at
a time.
 In php, there are three types of array:
. Indexed Array
. Associative Array
. Multidimensional Array
Arrays(contd..)
1.Indexed array: An array with numeric index.
Example:
$cars = array("Volvo", "BMW", "Toyota");
or
$cars[0] = "Volvo";
$cars[1] = "BMW";
$cars[2] = "Toyota";
Arrays(contd..)
2.Associative array: An array where each ID key is associated with a
value.
Example:
$salary = array(
"Peter"=>“2000",
"Ben"=>“3000",
"Joe"=>“4000“ );
Arrays(contd..)
3.Multidimensional array: An array containing one or more arrays
and values are accessed using multiple indices.
Example:
<?php
$letters = array('A','B','C'); $numbers =
array(1,2,3);
$matrix = array('Letter' =>$letters,
'Number' => $numbers);
?>
Operators
 Arithmetic operator
 Logical operator
 Assignment operator
 Comparison operator
 String operator
$total=$x+$y
$x and $Y
$z=$x+$yor(=+,=-)
$x==$y
$txt1.$txt2
Php- if..elseif..else
if (condition1) {
//code to be executed;
} elseif (condition2) {
//Code to be executed;
} else {
//code to be executed if neither;
// condition1 nor condition2 is true;
}
Php-Switch statement
$favcolor=“red”;
switch($favcolor){
case “red”:
echo ” your favorite color is red”;
break;
case “blue”:
echo ” your favorite color is blue”;
break;
default:
echo “ ..neither red or blue ”;
Loops
 while:
$x=1;
while ($x<=5){
echo “Number: $x</br>”; $x++;
}
dowhile: $x=1;
do
{
echo ” Number: $x</br>”; $x++;
}while ($x<=5);
Loops(contd)
 For Loop:
<?php
for ($x=0; %x<=10; $x++)
{
echo “ The number is: $x </br> ”;
}
?>
Loops(contd)
 foreach Loop: The foreach loop works only on arrays, and used to
loop through keys/value pair in an array.
<?php
$color=array(“red”,”green”,”blue”;
foreach ($color as $ value)
echo “$value</br>”;
?>
Functions
 A Function is a self-contained block of code that performs to
perform specific task.
 Php Built-in functions.
 Php User-defined functions.
function functionName(){
// code to executed;}
 Php functions with Parameters.
function functionName($parameter1,$parameter2){
//Code to executed; }
Mysql connection
 Create connection: Before we can access data in the MySQL database, we
need to be able to connect to the server:
$conn = new mysqli($servername, $username, $password);
 Close connection: The connection will be closed automatically when the
script ends.
$conn->close();
Mysql database
 Create database: The CREATE DATABASE statement is used to
create a database in MySQL.
$sql = “create database myDB";
if ($conn->query($sql) === TRUE) {
echo "Database created successfully";
} else {
echo "Error creating database: " . $conn->error;
}
Mysql connection
 Create table: The create table statement is used to create a table
in MySQL.
create table MyGuests (
id int(6) unsined
auto_increment primary key,
firstname varchar(30) not null,
lastname varchar(30) not null,
email varchar(50),
reg_date timestamp
);
Mysql database
 Insert values: After creating the database and table start inserting
the values to the database.
INSERT INTO table name (column1, column2,
column3,...)VALUES (value1, value2, value3,...);
 Update data: The UPDATE statement is used to update existing
records in a table.
Update table_name
SET column1=value, column2=value2,...
WHERE some column=some_value
Frameworks
A Frame is a set of common and prefabricated software building
blocks that programmers can use, extend customize for specific
computing solutions.
1. Code Igniter.
2. CakePHP.
3. PHPDevShell.
4. Akelos.

More Related Content

What's hot

PHP 2
PHP 2PHP 2
PHP 2
Richa Goel
 
PHP and Databases
PHP and DatabasesPHP and Databases
PHP and Databases
Things Lab
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
Bradley Holt
 
MySQLi - An Improved Extension of MySQL
MySQLi - An Improved Extension of MySQLMySQLi - An Improved Extension of MySQL
MySQLi - An Improved Extension of MySQL
Global Codester
 
PHP Programming: Intro
PHP Programming: IntroPHP Programming: Intro
PHP Programming: Intro
Things Lab
 
Php Mysql
Php Mysql Php Mysql
Php Mysql
Mudasir Syed
 
PHP-Part4
PHP-Part4PHP-Part4
PHP-Part4
Ahmed Saihood
 
Check username availability with vue.js and PHP
Check username availability with vue.js and PHPCheck username availability with vue.js and PHP
Check username availability with vue.js and PHP
Yogesh singh
 
Php MySql For Beginners
Php MySql For BeginnersPhp MySql For Beginners
Php MySql For Beginners
Priti Solanki
 
Web 10 | PHP with MySQL
Web 10 | PHP with MySQLWeb 10 | PHP with MySQL
Web 10 | PHP with MySQL
Mohammad Imam Hossain
 
Web Design EJ3
Web Design EJ3Web Design EJ3
Web Design EJ3
Aram Mohammed
 
PHP-Part3
PHP-Part3PHP-Part3
PHP-Part3
Ahmed Saihood
 
PHP Basic
PHP BasicPHP Basic
PHP Basic
Yoeung Vibol
 
Php, mysq lpart1
Php, mysq lpart1Php, mysq lpart1
Php, mysq lpart1
Subhasis Nayak
 
Php, mysq lpart4(processing html form)
Php, mysq lpart4(processing html form)Php, mysq lpart4(processing html form)
Php, mysq lpart4(processing html form)
Subhasis Nayak
 
Web technology html5 php_mysql
Web technology html5 php_mysqlWeb technology html5 php_mysql
Web technology html5 php_mysql
durai arasan
 
Php talk
Php talkPhp talk
Php talk
Jamil Ramsey
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...webhostingguy
 

What's hot (20)

PHP 2
PHP 2PHP 2
PHP 2
 
PHP and Databases
PHP and DatabasesPHP and Databases
PHP and Databases
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
MySQLi - An Improved Extension of MySQL
MySQLi - An Improved Extension of MySQLMySQLi - An Improved Extension of MySQL
MySQLi - An Improved Extension of MySQL
 
PHP Programming: Intro
PHP Programming: IntroPHP Programming: Intro
PHP Programming: Intro
 
Php Mysql
Php Mysql Php Mysql
Php Mysql
 
PHP-Part4
PHP-Part4PHP-Part4
PHP-Part4
 
Check username availability with vue.js and PHP
Check username availability with vue.js and PHPCheck username availability with vue.js and PHP
Check username availability with vue.js and PHP
 
Php MySql For Beginners
Php MySql For BeginnersPhp MySql For Beginners
Php MySql For Beginners
 
Web 10 | PHP with MySQL
Web 10 | PHP with MySQLWeb 10 | PHP with MySQL
Web 10 | PHP with MySQL
 
Operators in PHP
Operators in PHPOperators in PHP
Operators in PHP
 
Web Design EJ3
Web Design EJ3Web Design EJ3
Web Design EJ3
 
PHP-Part3
PHP-Part3PHP-Part3
PHP-Part3
 
PHP Basic
PHP BasicPHP Basic
PHP Basic
 
Php, mysq lpart1
Php, mysq lpart1Php, mysq lpart1
Php, mysq lpart1
 
Php, mysq lpart4(processing html form)
Php, mysq lpart4(processing html form)Php, mysq lpart4(processing html form)
Php, mysq lpart4(processing html form)
 
PHP and MySQL
PHP and MySQLPHP and MySQL
PHP and MySQL
 
Web technology html5 php_mysql
Web technology html5 php_mysqlWeb technology html5 php_mysql
Web technology html5 php_mysql
 
Php talk
Php talkPhp talk
Php talk
 
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...PHP and MySQL PHP Written as a set of CGI binaries in C in ...
PHP and MySQL PHP Written as a set of CGI binaries in C in ...
 

Similar to Php

Introduction to php
Introduction to phpIntroduction to php
Introduction to php
Taha Malampatti
 
php&mysql with Ethical Hacking
php&mysql with Ethical Hackingphp&mysql with Ethical Hacking
php&mysql with Ethical Hacking
BCET
 
FYBSC IT Web Programming Unit IV PHP and MySQL
FYBSC IT Web Programming Unit IV  PHP and MySQLFYBSC IT Web Programming Unit IV  PHP and MySQL
FYBSC IT Web Programming Unit IV PHP and MySQL
Arti Parab Academics
 
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Muhamad Al Imran
 
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Muhamad Al Imran
 
Php interview-questions and answers
Php interview-questions and answersPhp interview-questions and answers
Php interview-questions and answers
sheibansari
 
Php a dynamic web scripting language
Php   a dynamic web scripting languagePhp   a dynamic web scripting language
Php a dynamic web scripting language
Elmer Concepcion Jr.
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
Starting with PHP and Web devepolment
Starting with PHP and Web devepolmentStarting with PHP and Web devepolment
Starting with PHP and Web devepolment
Rajib Ahmed
 
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
anshkhurana01
 
Php by shivitomer
Php by shivitomerPhp by shivitomer
Php by shivitomer
Shivi Tomer
 
php-mysql-tutorial-part-3
php-mysql-tutorial-part-3php-mysql-tutorial-part-3
php-mysql-tutorial-part-3tutorialsruby
 
&lt;b>PHP&lt;/b>/MySQL &lt;b>Tutorial&lt;/b> webmonkey/programming/
&lt;b>PHP&lt;/b>/MySQL &lt;b>Tutorial&lt;/b> webmonkey/programming/&lt;b>PHP&lt;/b>/MySQL &lt;b>Tutorial&lt;/b> webmonkey/programming/
&lt;b>PHP&lt;/b>/MySQL &lt;b>Tutorial&lt;/b> webmonkey/programming/tutorialsruby
 
php-mysql-tutorial-part-3
php-mysql-tutorial-part-3php-mysql-tutorial-part-3
php-mysql-tutorial-part-3tutorialsruby
 
PHP and MySQL.ppt
PHP and MySQL.pptPHP and MySQL.ppt
PHP and MySQL.ppt
ROGELIOVILLARUBIA
 
Php interview questions
Php interview questionsPhp interview questions
Php interview questions
sekar c
 
Php session
Php sessionPhp session
Php session
argusacademy
 
Fnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
Fnt Software Solutions Pvt Ltd Placement Papers - PHP TechnologyFnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
Fnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
fntsofttech
 

Similar to Php (20)

Introduction to php
Introduction to phpIntroduction to php
Introduction to php
 
php&mysql with Ethical Hacking
php&mysql with Ethical Hackingphp&mysql with Ethical Hacking
php&mysql with Ethical Hacking
 
FYBSC IT Web Programming Unit IV PHP and MySQL
FYBSC IT Web Programming Unit IV  PHP and MySQLFYBSC IT Web Programming Unit IV  PHP and MySQL
FYBSC IT Web Programming Unit IV PHP and MySQL
 
Php i basic chapter 3
Php i basic chapter 3Php i basic chapter 3
Php i basic chapter 3
 
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
Php i basic chapter 3 (syahir chaer's conflicted copy 2013-04-22)
 
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
Php i basic chapter 3 (afifah rosli's conflicted copy 2013-04-23)
 
Php interview-questions and answers
Php interview-questions and answersPhp interview-questions and answers
Php interview-questions and answers
 
Php a dynamic web scripting language
Php   a dynamic web scripting languagePhp   a dynamic web scripting language
Php a dynamic web scripting language
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
Starting with PHP and Web devepolment
Starting with PHP and Web devepolmentStarting with PHP and Web devepolment
Starting with PHP and Web devepolment
 
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
Php mysql classes in navi-mumbai,php-mysql course provider-in-navi-mumbai,bes...
 
Php by shivitomer
Php by shivitomerPhp by shivitomer
Php by shivitomer
 
php-mysql-tutorial-part-3
php-mysql-tutorial-part-3php-mysql-tutorial-part-3
php-mysql-tutorial-part-3
 
&lt;b>PHP&lt;/b>/MySQL &lt;b>Tutorial&lt;/b> webmonkey/programming/
&lt;b>PHP&lt;/b>/MySQL &lt;b>Tutorial&lt;/b> webmonkey/programming/&lt;b>PHP&lt;/b>/MySQL &lt;b>Tutorial&lt;/b> webmonkey/programming/
&lt;b>PHP&lt;/b>/MySQL &lt;b>Tutorial&lt;/b> webmonkey/programming/
 
php-mysql-tutorial-part-3
php-mysql-tutorial-part-3php-mysql-tutorial-part-3
php-mysql-tutorial-part-3
 
PHP and MySQL.ppt
PHP and MySQL.pptPHP and MySQL.ppt
PHP and MySQL.ppt
 
Php interview questions
Php interview questionsPhp interview questions
Php interview questions
 
Php session
Php sessionPhp session
Php session
 
Fnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
Fnt Software Solutions Pvt Ltd Placement Papers - PHP TechnologyFnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
Fnt Software Solutions Pvt Ltd Placement Papers - PHP Technology
 
lab4_php
lab4_phplab4_php
lab4_php
 

Recently uploaded

AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
Divya Somashekar
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
Kamal Acharya
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
ankuprajapati0525
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
VENKATESHvenky89705
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
WENKENLI1
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
AafreenAbuthahir2
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 

Recently uploaded (20)

AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
block diagram and signal flow graph representation
block diagram and signal flow graph representationblock diagram and signal flow graph representation
block diagram and signal flow graph representation
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 
Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Final project report on grocery store management system..pdf
Final project report on grocery store management system..pdfFinal project report on grocery store management system..pdf
Final project report on grocery store management system..pdf
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
The role of big data in decision making.
The role of big data in decision making.The role of big data in decision making.
The role of big data in decision making.
 
road safety engineering r s e unit 3.pdf
road safety engineering  r s e unit 3.pdfroad safety engineering  r s e unit 3.pdf
road safety engineering r s e unit 3.pdf
 
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdfGoverning Equations for Fundamental Aerodynamics_Anderson2010.pdf
Governing Equations for Fundamental Aerodynamics_Anderson2010.pdf
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234WATER CRISIS and its solutions-pptx 1234
WATER CRISIS and its solutions-pptx 1234
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 

Php

  • 2. Index 1. What is php? 2. Uses of php 3. Basic syntax of php 4. Variables 5. Echo/print statement 6. Array 7. Decision making 8. Loops 9. Functions 10. Mysql connections to php 11. Framework
  • 3. What is php ?  Php is scripting language commonly used on web servers.  stands for Php: Hypertext preprocessor.  open source.  Embedded code.  Multiple operating systems/web servers.
  • 4. Uses of php  Programming functions.  You can add, delete, modify, etc within database through php.  Encrypt data.  Using PHP, you can restrict users to access some pages of your website.
  • 5. Basic php syntax <html> <head> <title></title> </head> <body> <?php echo “Hello!PHP”; //prints Hello!PHP ?> </body> </html>
  • 6.  Comment: To make the single line comment use //.To make large comment block use /* and ends with */. Example: <?php //this is comment /*this is comment Block*/ ?>
  • 7. Variables  Php variables start with $ sign and followed by name of variable.  Case sensitive($FOO!=$foo!=fOo)  Globally and locally scoped variable  Global variables can be placed anywhere.  Local variables restricted to a function or class.  Certain variables are reserved by php  Form variables($_post,$_get)  Server variables($_server),etc.
  • 8. Variables usage Example: <?php $txt = "Hello world!"; $x = 5; $y = 5.44; echo $txt; // prints Hello world! echo ”br”; echo $x; // prints 5 echo “br”; echo $y; // prints 5.44 ?>
  • 9. Echo/Print  There are two ways to print the output: echo and print Example: <?php $foo = 25; $bar = “Well come to php”; echo $bar; //prints Well come to php echo $foo; //prints 25 echo $foo,$bar; //prints 25hello ?>
  • 10. Arrays  An array is a special variable that stores more than one element at a time.  In php, there are three types of array: . Indexed Array . Associative Array . Multidimensional Array
  • 11. Arrays(contd..) 1.Indexed array: An array with numeric index. Example: $cars = array("Volvo", "BMW", "Toyota"); or $cars[0] = "Volvo"; $cars[1] = "BMW"; $cars[2] = "Toyota";
  • 12. Arrays(contd..) 2.Associative array: An array where each ID key is associated with a value. Example: $salary = array( "Peter"=>“2000", "Ben"=>“3000", "Joe"=>“4000“ );
  • 13. Arrays(contd..) 3.Multidimensional array: An array containing one or more arrays and values are accessed using multiple indices. Example: <?php $letters = array('A','B','C'); $numbers = array(1,2,3); $matrix = array('Letter' =>$letters, 'Number' => $numbers); ?>
  • 14. Operators  Arithmetic operator  Logical operator  Assignment operator  Comparison operator  String operator $total=$x+$y $x and $Y $z=$x+$yor(=+,=-) $x==$y $txt1.$txt2
  • 15. Php- if..elseif..else if (condition1) { //code to be executed; } elseif (condition2) { //Code to be executed; } else { //code to be executed if neither; // condition1 nor condition2 is true; }
  • 16. Php-Switch statement $favcolor=“red”; switch($favcolor){ case “red”: echo ” your favorite color is red”; break; case “blue”: echo ” your favorite color is blue”; break; default: echo “ ..neither red or blue ”;
  • 17. Loops  while: $x=1; while ($x<=5){ echo “Number: $x</br>”; $x++; } dowhile: $x=1; do { echo ” Number: $x</br>”; $x++; }while ($x<=5);
  • 18. Loops(contd)  For Loop: <?php for ($x=0; %x<=10; $x++) { echo “ The number is: $x </br> ”; } ?>
  • 19. Loops(contd)  foreach Loop: The foreach loop works only on arrays, and used to loop through keys/value pair in an array. <?php $color=array(“red”,”green”,”blue”; foreach ($color as $ value) echo “$value</br>”; ?>
  • 20. Functions  A Function is a self-contained block of code that performs to perform specific task.  Php Built-in functions.  Php User-defined functions. function functionName(){ // code to executed;}  Php functions with Parameters. function functionName($parameter1,$parameter2){ //Code to executed; }
  • 21. Mysql connection  Create connection: Before we can access data in the MySQL database, we need to be able to connect to the server: $conn = new mysqli($servername, $username, $password);  Close connection: The connection will be closed automatically when the script ends. $conn->close();
  • 22. Mysql database  Create database: The CREATE DATABASE statement is used to create a database in MySQL. $sql = “create database myDB"; if ($conn->query($sql) === TRUE) { echo "Database created successfully"; } else { echo "Error creating database: " . $conn->error; }
  • 23. Mysql connection  Create table: The create table statement is used to create a table in MySQL. create table MyGuests ( id int(6) unsined auto_increment primary key, firstname varchar(30) not null, lastname varchar(30) not null, email varchar(50), reg_date timestamp );
  • 24. Mysql database  Insert values: After creating the database and table start inserting the values to the database. INSERT INTO table name (column1, column2, column3,...)VALUES (value1, value2, value3,...);  Update data: The UPDATE statement is used to update existing records in a table. Update table_name SET column1=value, column2=value2,... WHERE some column=some_value
  • 25. Frameworks A Frame is a set of common and prefabricated software building blocks that programmers can use, extend customize for specific computing solutions. 1. Code Igniter. 2. CakePHP. 3. PHPDevShell. 4. Akelos.