Module 7 PHP Mysql
Module 7 PHP Mysql
PHP MYSQL
What is MySQL?
MySQL is a database.
The world most popular open-source database.
Companies using MySQL are Yahoo!, Google, Cisco, NASA and HP.
The data in MySQL is stored in database objects called tables.
PHPMyAdmin
Basic SQL
Creating Database
Syntax:
Creating Tables
Syntax:
Inserting Records
dnnelcaguin 1
Urdaneta City University Elective 102: Server Side Coding
College of Computer Studies Module 7: PHP MySql
Syntax:
Updating Records
Syntax:
Deleting Records
Syntax:
MySQL Database
Syntax:
mysqli_connect(servername,username,password,database);
Parameter Description
Servername Optional. Specifies the server to connect to. Default value is
"localhost:3306"
Username Optional. Specifies the username to log in with. Default value is the name
of the user that owns the server process
Password Optional. Specifies the password to log in with. Default is ""
Database name Specifies the database name.
<?php
$dbconnect = mysqli_connect(‘localhost’,’root’,’’,’dbname’) or
die(mysqli_error());
//localhost hostname
//root username
//passpassword
//dbnamedatabase name
//mysqli_error()error id
?>
dnnelcaguin 2
Urdaneta City University Elective 102: Server Side Coding
College of Computer Studies Module 7: PHP MySql
mysqli_query();
Example:
mysqli_close($dbconnect);
mysqli_query($query,$dbconnect);
mysqli_query($query,$dbconnect);
mysqli_query($query,$dbconnect);
mysqli_query()
<?php
$result = mysqli_query($query,$dbconnect)’
?>
dnnelcaguin 3