PHP AND MySQL
Syllabus:
PHP : Introduction to PHP, Evaluation of Php, Basic Syntax, Defining variable and constant, Php Data
type, Operator and Expression, Decisions and looping, Functions , Arrays, Handling Html Form with Php
Capturing Form, Data Dealing with Multi-value filed, and Generating File uploaded form, redirecting a
form after submission, Files, Session and Cookie Introduction to Session Control, Session Functionality
What is a Cookie, Setting Cookies with PHP. Using Cookies with Sessions, Deleting Cookies,
Registering Session variables, Destroying the variables and Session.
MY SQL: Database Connectivity with MySql Introduction to RDBMS, Connection with MySql
Database, Performing basic database operation(DML) (Insert, Delete, Update, Select), Setting query
parameter, Executing queryJoin (Cross joins, Inner joins, Outer Joins, Self joins.), Exception Handling
Understanding Exception and error, Try, catch, throw. Error tracking and debugging.
Schedule:
S.No Date Topic Periods
Introduction to PHP, Evaluation of Php, Basic Syntax,
1. 24.04.2023 Defining variable and constant, Php Data type, 6
Operator and Expression
Decisions and looping, Functions , Arrays, Handling
Html Form with Php Capturing Form, Data Dealing
2. 25.04.2023 6
with Multi-value filed, and Generating File uploaded
form, redirecting a form after submission,
Files,Session and Cookie Introduction to Session
Control, Session Functionality What is a Cookie,
3. 26.04.2023 Setting Cookies with PHP. Using Cookies with 6
Sessions, Deleting Cookies, Registering Session
variables, Destroying the variables and Session.
Database Connectivity with MySql Introduction to
RDBMS, Connection with MySql Database,
4. 02.05.2023 6
Performing basic database operation(DML) (Insert,
Delete, Update, Select),
Setting query parameter, Executing queryJoin (Cross
joins, Inner joins, Outer Joins, Self joins.), Exception
5. 03.05.2023 6
Handling Understanding Exception and error, Try, catch,
throw. Error tracking and debugging.
Subject Handling: Mr. N.Nandakumar, AP/AI&DS
Ms,A.Yasmin, AP/AI&DS
Course Objectives
The course is intended to
1. Familiarize the fundamentals of data models and SQL
2. Represent a database system using ER diagrams and relational schema
3. Understand the fundamental concepts of transaction processing- concurrency control Techniques
and recovery procedures
4. Identify with the internal storage structures using different file and indexing techniques which will
help in physical database design.
5. Have a comparative knowledge about the various advanced databases.
Course Outcomes
On successful completion of the course, students will be able to
Bloom's
CO.No. Course Outcome
Level
Classify the modern and futuristic database applications and write queries using
CO1. Understand
various SQL commands
Construct ER Model and Design relational schema for a given database
CO2. Analyze
application..
CO3. Illustrate the concepts for transaction processing and concurrency control.. Evaluate
CO4. Use various testing methods and verify Apply indexing and hashing techniques to Apply
access and generate user reports for a database.
CO5. Appraise how advanced databases differ from traditional databases Analyze
Introduction of PHP:
PHP is an open-source, interpreted, and object-oriented scripting language that can
be executed at the server-side. PHP is well suited for web development. Therefore, it is used to
develop web applications (an application that executes on the server and generates the dynamic
page.).
PHP was created by Rasmus Lerdorf in 1994 but appeared in the market in 1995. PHP 7.4.0 is the
latest version of PHP, which was released on 28 November.
PHP stands for Hypertext Preprocessor.
PHP is an interpreted language, i.e., there is no need for compilation.
PHP is faster than other scripting languages, for example, ASP and JSP.
PHP is a server-side scripting language, which is used to manage the dynamic content of
the website.
PHP can be embedded into HTML.
PHP is an object-oriented language.
PHP is an open-source scripting language.
PHP is simple and easy to learn language.
Basic Syntax:
Generally, a PHP file contains HTML tags and some PHP scripting code. It is very easy
to create a simple PHP example. To do so, create a file and write HTML tags + PHP code and save
this file with .php extension.
<!DOCTYPE>
<html>
<body>
<?php
echo "<h2>Hello First PHP</h2>";
?>
</body>
</html>
PHP variables:
PHP, a variable is declared using a $ sign followed by the variable name. Here, some important points to
know about variables:
o As PHP is a loosely typed language, so we do not need to declare the data types of the
variables. It automatically analyzes the values and makes conversions to its correct
datatype.
o After declaring a variable, it can be reused throughout the code.
o Assignment Operator (=) is used to assign the value to a variable.
PHP Variable: Declaring string, integer, and float
Let's see the example to store string, integer, and float values in PHP variables.
<?php
$str="hello string";
$x=200;
$y=44.6;
echo "string is: $str <br/>";
echo "integer is: $x <br/>";
echo "float is: $y <br/>";
?>
PHP Constants:
PHP constants are name or identifier that can't be changed during the execution of the script
except for magic constants, which are not really constants. PHP constants can be defined by 2 ways:
1. Using define() function
2. Using const keyword
PHP constant: define()
Use the define() function to create a constant. It defines constant at run time. Let's see the
syntax of define() function in PHP.
Example:
<?php
define("MESSAGE","Hello JavaTpoint PHP");
echo MESSAGE;
?>
PHP constant: const keyword
PHP introduced a keyword const to create a constant. The const keyword defines
constants at compile time. It is a language construct, not a function. The constant defined using
const keyword are case-sensitive.
PHP Data Types
PHP data types are used to hold different types of data or values. PHP supports 8 primitive
data types that can be categorized further in 3 types:
Scalar Types (predefined)
Compound Types (user-defined)
Special Types
PHP Data Types: Scalar Types
It holds only single value. There are 4 scalar data types in PHP.
boolean
integer
float
string
PHP Data Types: Compound Types
It can hold multiple values. There are 2 compound data types in PHP.
array
object
PHP Operators
PHP Operator is a symbol i.e used to perform operations on operands. In simple words,
operators are used to perform operations on variables or values.
For example: $num=10+20;//+ is the operator and 10,20 are operands
PHP Operators can be categorized in following forms:
Arithmetic Operators
Assignment Operators
Bitwise Operators
Comparison Operators
Incrementing/Decrementing Operators
Logical Operators
String Operators
Array Operators
Type Operators
Execution Operators
Error Control Operators
PHP Conditional Statements:
Very often when you write code, you want to perform different actions for different
conditions. You can use conditional statements in your code to do this.
In PHP we have the following conditional statements:
if statement - executes some code if one condition is true
if...else statement - executes some code if a condition is true and another code if that
condition is false
if...elseif...else statement - executes different codes for more than two conditions
switch statement - selects one of many blocks of code to be executed
PHP Loops
Often when you write code, you want the same block of code to run over and over again a
certain number of times. So, instead of adding several almost equal code-lines in a script, we can
use loops.
Loops are used to execute the same block of code again and again, as long as a certain condition is
true.
In PHP, we have the following loop types:
while - loops through a block of code as long as the specified condition is true
do...while - loops through a block of code once, and then repeats the loop as long as the
specified condition is true
for - loops through a block of code a specified number of times
foreach - loops through a block of code for each element in an array
PHP Functions:
The real power of PHP comes from its functions. PHP has more than 1000 built-in
functions, and in addition you can create your own custom functions.
PHP Built-in Functions
PHP has over 1000 built-in functions that can be called directly, from within a script, to
perform a specific task.
Please check out our PHP reference for a complete overview of the PHP built-in functions.
PHP User Defined Functions
Besides the built-in PHP functions, it is possible to create your own functions.
A function is a block of statements that can be used repeatedly in a program.
A function will not execute automatically when a page loads.
A function will be executed by a call to the function.
Create a User Defined Function in PHP
A user-defined function declaration starts with the word function: Syntax:
Function functionName()
{ code to be executed;
}
Arrays in PHP:
An array is a special variable, which can hold more than one value at a time.If you have a
list of items (a list of car names, for example), storing the cars in single variables could look like
this:
$cars1="Volvo";
$cars2="BMW";
$cars3 = "Toyota";
Create an Array in PHP
In PHP, the array() function is used to create an array:
array();
In PHP, there are three types of arrays:
Indexed arrays - Arrays with a numeric index
Associative arrays - Arrays with named keys
Multidimensional arrays - Arrays containing one or more arrays
PHP Form Handling
The example below displays a simple HTML form with two input fields and a submit
button:
<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>
</body>
</html>
PHP Cookies:
A cookie is often used to identify a user. A cookie is a small file that the server embeds on
the user's computer. Each time the same computer requests a page with a browser, it will send the
cookie too. With PHP, you can both create and retrieve cookie values.
Create Cookies With PHP
A cookie is created with the setcookie() function.
Syntax:
setcookie(name, value, expire, path, domain, secure, httponly);
PHP Create/Retrieve a Cookie:
The following example creates a cookie named "user" with the value "John Doe". The
cookie will expire after 30 days (86400 * 30). The "/" means that the cookie is available in entire
website (otherwise, select the directory you prefer).
We then retrieve the value of the cookie "user" (using the global variable $_COOKIE). We also use
the isset() function to find out if the cookie is set:
My SQL
MySQL is a database system used on the web
MySQL is a database system that runs on a server
MySQL is ideal for both small and large applications
MySQL is very fast, reliable, and easy to use
MySQL uses standard SQL
MySQL compiles on a number of platforms
MySQL is free to download and use
MySQL is developed, distributed, and supported by Oracle Corporation
MySQL is named after co-founder Monty Widenius's daughter: My
PHP + MySQL Database System:
PHP combined with MySQL are cross-platform (you can develop in Windows and serve
on a Unix platform)
Database Queries:
A query is a question or a request.
We can query a database for specific information and have a recordset returned.
Look at the following query (using standard SQL):
SELECT LastName FROM Employees
PHP Connect to MySQL
PHP 5 and later can work with a MySQL database using:
MySQLi extension (the "i" stands for improved)
PDO (PHP Data Objects)
Earlier versions of PHP used the MySQL extension. However, this extension was deprecated in
2012.
Should I Use MySQLi or PDO?
If you need a short answer, it would be "Whatever you like".
Both MySQLi and PDO have their advantages:
PDO will work on 12 different database systems, whereas MySQLi will only work with
MySQL databases.
So, if you have to switch your project to use another database, PDO makes the process
easy. You only have to change the connection string and a few queries. With MySQLi,
you will need to rewrite the entire code - queries included.
Both are object-oriented, but MySQLi also offers a procedural API.
Both support Prepared Statements. Prepared Statements protect from SQL injection, and
are very important for web application security.
MySQL Examples in Both MySQLi and PDO Syntax
In this, and in the following chapters we demonstrate three ways of working
with PHP and MySQL:
MySQLi (object-oriented)
MySQLi (procedural)
PDO
EXCEL ENGINEERING COLLEGE
(Autonomous)
Approved by AICTE, New Delhi & Affiliated to Anna University, Chennai
Accredited by NBA (AERO,CSE,ECE MECH), NAAC with “A+” and Recognised by UGC (2f &12B)
KOMARAPALAYAM - 637303
Department of Artificial Intelligence and Data Science
Participants List
S.No. Reg.No. Roll No Student Name
1 730921201001 21AD001 AARIFF.M
2 730921201002 21AD002 AKSHAYA.M
3 730921201003 21AD003 AMAN SHAHABAS P.T.K
4 730921201004 21AD004 ANANDRAJ.M
5 730921201005 21AD005 ARUL SANJEEV DEEN.S
6 730921201006 21AD006 ARVETI SATISH BABU
7 730921201007 21AD007 ARYAN KUMAR
AVULA VISHNUVARDHU
8
730921201008 21AD008
REDDY
9 730921201009 21AD009 BABU PRASATH.M
10 730921201010 21AD010 BERBIN JOE.J
11 730921201011 21AD011 BUDILI JASWANTH REDDY
12 730921201012 21AD012 DHACHINAMOORTHI.M
13 730921201013 21AD013 DHARANEESH.M.B
14 730921201015 21AD015 DIVYA.G
15 730921201016 21AD016 GOMATHI.S
16 730921201017 21AD017 GOWTHAM.S
17 730921201018 21AD018 JANARTHANAN.S
18 730921201019 21AD019 JINU.P
19 730921201020 21AD020 JOHNAJAY.J
20 730921201021 21AD021 KALAISELVAN.R
21 730921201022 21AD022 KAVIN.M
22 730921201023 21AD023 KAVINSARATHI.S
23 730921201024 21AD024 KAYALVIZHI.R
24 730921201025 21AD025 KIRUPAKARAN.K
25 730921201026 21AD026 LINDA LANCE
26 730921201027 21AD027 MAJALA JINDO.J
27 730921201028 21AD028 MALLELA BHARATH
28 730921201029 21AD029 MARAM SIVABALAJI
29 730921201030 21AD030 MATHANKUMAR
30 730921201031 21AD031 MEHALLAN.B
31 730921201033 21AD033 MOHAMED AQEEL
32 730921201034 21AD034 MOUNIKA PRIYA.S
33 730921201037 21AD037 MUTHURAMYA.S
34 730921201038 21AD038 NAVEEN.R
35 730921201040 21AD040 PAMIDAKULA VENKATA SAI
36 730921201041 21AD041 PRAKASH.V
37 730921201042 21AD042 PRATHISON.A
38 730921201043 21AD043 PRATHIUSH CHANDRA.P
39 730921201044 21AD044 PRINCE KUMAR
40 730921201045 21AD045 RAVIKUMAR.R
41 730921201046 21AD046 ROHIT.M.JITH
42 730921201047 21AD047 RUBAN.B
43 730921201048 21AD048 SANJAY.V
44 730921201049 21AD049 SATHIASHRI.K
45 730921201050 21AD050 SATHISHKUMAR.T
46 730921201051 21AD051 SELVA KUMAR.E
47 730921201052 21AD052 SELVAKUMAR.J
48 730921201053 21AD053 SREEHARAN.P
49 730921201054 21AD054 SRUTHIKASUBHIKSHA
50 730921201055 21AD055 SUGANESH.A
51 730921201056 21AD056 SUMANKANTH.K
52 730921201057 21AD057 SUSHMI.D
53 730921201058 21AD058 THARUN ATITHYA.B
54 730921201059 21AD059 THRISHA.M.S
55 730921201061 21AD061 VASANTHKUMAR.V.M
56 730921201062 21AD062 YERASI VENUGOPAL REDDY
57 730921201063 21AD063 YOGESH.P
58 22EGLAI001 22LAD064 HARRISON RALPH
59 22EMLAI002 22LAD065 RAMA KRISHNAN
60 22EMLAI005 22LAD066 PRATEEK SINHA
61 22EMLAI004 22LAD067 DHINOOP BAIJU
EXCEL ENGINEERING COLLEGE
(Autonomous)
Approved by AICTE, New Delhi & Affiliated to Anna University, Chennai
Accredited by NBA (AERO,CSE,ECE MECH), NAAC with “A+” and Recognised by UGC (2f &12B)
KOMARAPALAYAM - 637303
Department of Artificial Intelligence and Data Science
EXCEL ENGINEERING COLLEGE
(Autonomous)
Approved by AICTE, New Delhi & Affiliated to Anna University, Chennai
Accredited by NBA (AERO,CSE,ECE MECH), NAAC with “A+” and Recognised by UGC (2f
&12B)
KOMARAPALAYAM - 637303
Department of Artificial Intelligence and Data Science
Summary Report
Department of Artificial Intelligence and Data Science Organized
Values added course on PHP & My SQL to students of II year AI&DS on
24.04.2023 to 26.04.2023 & 02/05/2023 to 03/05/2023.
PHP is a server side scripting language that is embedded in HTML. It is
used to manage dynamic content, databases, session tracking, even build
entire e-commerce sites.It is integrated with a number of popular databases,
including MySQL, PostgreSQL, Oracle, Sybase, Informix, and Microsoft
SQL Server. MySQL is an open-source relational database management
system
PHP and MySQL are open-source server-side programming languages used
to create dynamic websites. They provide flexibility, as they can be used and
manipulated on any operating system. PHP and MySQL work together to provide
fast web page response times even with slow internet and data speed.
We may utilize PHP as a backend for Android application development using.
With PHP and MySQL, you will effectively establish an Android login. Some
sample projects include the test android folder, which contains PHP scripts. PHP
will help you build a robust backend for your application.