You are on page 1of 17

XII STD B1

(COMPUTER APPLICATIONS)

K. NOOR AHAMED, M.C.A.,


(COMPUTER INSTRUCTOR)
CHAPTER – 9
CONTENT:

 Introduction to Database

 Introduction to MySQL Database

 MySQL Function in PHP

 Connecting PHP with MySQL


DATABASE & TABLES
 DATABASE – Place where we can store, retrieve and manage data.

 DATA is stored in the DATABASE in the form of TABLES.

 TABLE is defined as the collection of data organized in terms of


ROWS and COLUMNS.

ROW COLUMN

RECORD FIELD

TUPLE ATTRIBUTE
DBMS (Data Base Management System)

 A Database Management System (DBMS) is System Software


for creating and managing Databases.

MYSQL
 MySQL is a Relational Database Management System (RDBMS) found
by MONTY WIDENIUS and is named after his daughter name MY.

 SQL is a STRUCTURED QUERY LANGUAGE used to access


the DATABASE and the DATA.
OTHER RELATIONAL DATABASES (RDBMS)
MySQLi() Functions
 MySQLi – is the extension in PHP to access the MYSQL Database.

mysqli_connect() 4 Version
mysqli_connect_error () 0 5.0.0
mysqli_close() 1
mysqli_select_db() 2
PARAMETERS
mysqli_affected_rows() 1
mysqli_fetch_assoc() 1
mysqli_query() 2
mysqli_connect()
4
SYNTAX mysqli_connect ( “Server Name” ,
“User Name” ,
“Password” ,

<?php
“Database Name” ); EXAMPLE
$servername = “localhost”;
$username = “username”;
$password = “password”;
$DB_name = “School_DB”;
$con = mysqli_connect ($servername, $username, $password, $DB_name);
?>
mysqli_connect_error()
0
SYNTAX
mysqli_connect_error()

EXAMPLE
if (!$con)
{
die(“Connection failed: ”. mysqli_connect_error());
}
mysqli_close()
1

SYNTAX
mysqli_close ( “connection object” );

EXAMPLE
mysqli_close($con);
mysqli_select_db()
2
SYNTAX

mysqli_select_db ( “connection object”,


“database name” );

EXAMPLE
mysqli_select_db ( $con, $db_name );
mysqli_affected_rows()
1
SYNTAX

mysqli_affected_rows ( “connection object”);

EXAMPLE
mysqli_affected_rows($con);
mysqli_fetch_assoc()
1
SYNTAX

mysqli_fetch_assoc ( “result row”);

EXAMPLE
mysqli_affected_rows($result);
mysqli_query()
2
SYNTAX

mysqli_query ( “connection object”, “sql query” );

EXAMPLE
$sql= "select * from mycontacts";
$result = mysqli_query ($con, $sql);
RECENT SURVEY

JAN 544
2018 Million
SOFTWARE FRAMEWORKS

You might also like