INTERNET APPLICATION DEVELOPMENT PRACTICAL ON CONNECTING TO MYSQL.

Slides:



Advertisements
Similar presentations
PHP SQL. Connection code:- mysql_connect("server", "username", "password"); Connect to the Database Server with the authorised user and password. Eg $connect.
Advertisements

PHP and MySQL Database. Connecting to MySQL Note: you need to make sure that you have MySQL software properly installed on your computer before you attempt.
Faculty of Sciences and Social Sciences HOPE PHP & MySQL Stewart Blakeway FML 213
PHP and MySQL PHP for the Web, page PHP and MySQL MySQL Resource PHP – MySQL Resource
Intermediate PHP & MySQL
What is MySQL? MySQL is a database. The data in MySQL is stored in database objects called tables. A table is a collections of related data entries and.
PHP1-1 PHP & SQL Xingquan (Hill) Zhu
© Yanbu University College YANBU UNIVERSITY COLLEGE Management Science Department © Yanbu University College Module 6:WEB SERVER AND SERVER SIDE SCRPTING,
Chapter 5 Introduction to SQL. Structured Query Language = the “programming language” for relational databases SQL is a nonprocedural language = the user.
MySQL in PHP – Page 1 of 17CSCI 2910 – Client/Server-Side Programming CSCI 2910 Client/Server-Side Programming Topic: MySQL in PHP Reading: Williams &
Internet and Web Application Development Revision.
INTERNET APPLICATION DEVELOPMENT For More visit:
Advanced Database Management System Lab no. 11. SQL Commands (for MySQL) –Update –Replace –Delete.
PHP MySQL Introduction
LOGO 1 Lab_02: Basic SQL. 2 Outline  Database Tables  SQL Statements  Semicolon after SQL Statements?  SQL DML and DDL  SQL SELECT Statement  SQL.
PHP Programming with MySQL Slide 8-1 CHAPTER 8 Working with Databases and MySQL.
 SQL stands for Structured Query Language.  SQL lets you access and manipulate databases.  SQL is an ANSI (American National Standards Institute) standard.
Structured Query Language. SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating database systems.
 Mysql – popular open-source database management system  PHP usually works with Mysql for web- based database applications  LAMP applications—Web-based.
Databases in Visual Studio. Database in VisualStudio An MS SQL database are built in Visual studio The Name can be something like ”(localdb)\Projects”
PHP Advance. Agenda Server side Includes File Handling Cookies Sessions Error/Exception handling Database handling with MySQL sending.
15/10/20151 PHP & MySQL 'Slide materials are based on W3Schools PHP tutorial, 'PHP website 'MySQL website.
Introduction to MySQL Lab no. 10 Advance Database Management System.
PHP MySQL Introduction. MySQL is the most popular open-source database system. What is MySQL? MySQL is a database. The data in MySQL is stored in database.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
SYST Web Technologies SYST Web Technologies Databases & MySQL.
INTERNET APPLICATION DEVELOPMENT Practical on Sessions.
Database and mySQL Week 07 Dynamic Web TCNJ Jean Chu.
CPS120: Introduction to Computer Science Lecture 19 Introduction to SQL.
MySQL Database Connection
Intro to DatabasesClass 4 SQL REVIEW To talk to the database, you have to use SQL SQL is used by many databases, not just MySQL. SQL stands for Structured.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP & MySQL.
PHP Database connectivity Connecting with RDBMS and editing, adding, and deleting databases therein are all done through PHP functions.
PHP Database Processing CIS 1715 Web Technologies.
SQL Basic. What is SQL? SQL (pronounced "ess-que-el") stands for Structured Query Language. SQL is used to communicate with a database.
Nic Shulver, Introduction to SQL Topics covered Structured Query Language What can it do? Advantages of SQL Why bother with SQL?
PHP and Mysql Database. PHP and Database Mysql – popular open-source database management system PHP usually works with Mysql for web-based database applications.
Module Review Basic SQL commands: Create Database, Create Table, Insert and Select 2. Connect an SQL Database to PHP 3. Execute SQL Commands in.
Web Scripting [PHP] CIS166AE Wednesdays 6:00pm – 9:50pm Rob Loy.
Creating a simple database This shows you how to set up a database using PHPMyAdmin (installed with WAMP)
PHP: MySQL. 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.
PHP Database Pemrograman Internet. PHP MySQL Database With PHP, you can connect to and manipulate databases. MySQL is the most popular database system.
CHAPTER 10 PHP MySQL Database
Introduction to PHP Brendan Knight. What is PHP PHP is a general-purpose scripting language originally designed for web development to produce dynamic.
MySQL MySQL and PHP – interacting with a database.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
PHP with MYSQL Please use speaker notes for additional information!
SQL Structured Query Language. SQL is an ANSI (American National Standards Institute) standard computer language for accessing and manipulating database.
 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.
PHP & MY SQL Instructor: Monireh H. Sayadnavard 1.
Tried my best to simplify it for you!
PHP: MySQL Lecture 14 Kanida Sinmai
Web Systems & Technologies
Chapter 5 Introduction to SQL.
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Open Source Server Side Scripting Permissions & Users
Session 4 PHP & MySQL.
Introduction to Web programming
PHP + MySQL Commands Refresher.
Using SQL Server through Command Prompt
ISC440: Web Programming 2 Server-side Scripting PHP 3
Lecturer: Mukhtar Mohamed Ali “Hakaale”
Chapter 8 Working with Databases and MySQL
MySQL Web Application Connecting to a MySQL database
Structured Query Language
PHP: Combo box FdSc Module 109 Server side scripting and
Web Programming– UFCFB Lecture
Introduction to Web programming
Conection
Presentation transcript:

INTERNET APPLICATION DEVELOPMENT PRACTICAL ON CONNECTING TO MYSQL

PHP MySQL Introduction What is MySQL? MySQL is the most popular open-source database system. The data in MySQL is stored in database objects called tables. A table is a collection of related data entries and it consists of columns and rows. Databases are useful when storing information categorically. A company may have a database with the following tables: "Employees", "Products", "Customers" and "Orders".

A database most often contains one or more tables. Each table is identified by a name (e.g. "Customers" or “students"). Tables contain records (rows) with data. Below is an example of a table called “students": The table above contains three records (one for each person) and four columns (LastName, FirstName, Address, and City). LastNameFirstNameAddressCity alnashriOlaTimoteivn 1Sandnes alahmadToveBorgvn 23Sandnes alshareefKariStorgt 20Stavanger

Queries A query is a question or a request. With MySQL, we can query a database for specific information and have a recordset returned. Look at the following query: SELECT LastName FROM students The query above selects all the data in the "LastName" column from the “students" table, and will return a recordset like this: LastName alnashri alahmad alshareef

PHP MySQL Connect to a Database Create a Connection to a MySQL Database Before you can access data in a database, you must create a connection to the database. In PHP, this is done with the mysql_connect() function. Syntax: mysql_connect(servername,username,password); ParameterDescription servernameOptional. Specifies the server to connect to. Default value is "localhost:3306" usernameOptional. Specifies the username to log in with. Default value is the name of the user that owns the server process passwordOptional. Specifies the password to log in with. Default is ""

How to add a new user to mysql Visit This will bring you to the MySQL setup page. choose the user classification as follow Then click on Add user

Add user will pops up. Type the user name and password then check all the global privileges. And finally click on add user.

Creating database using Mysql There are two ways to create a database: first way: 1)Visit This will bring you to the MySQL setup page. 2) Enter a name for the database, then click on the Create button. 3) Ensure the database was successfully created. Second way: through php code by using the next statement: mysql_query("CREATE DATABASE name_of_Db",connection)

Create a Table The CREATE TABLE statement is used to create a table in MySQL. Syntax CREATE TABLE table_name ( column_name1 data_type, column_name2 data_type, column_name3 data_type,.... ) We must add the CREATE TABLE statement to the mysql_query() function to execute the command. Example The following example creates a table named “students", with three columns. The column names will be "FirstName", "LastName" and “UID":

<?php $con = mysql_connect("localhost",“moh",“1414"); if (!$con) { die('Could not connect: '. mysql_error()); } // Create database if (mysql_query("CREATE DATABASE first_DB",$con)) { echo "Database created"; } else { echo "Error creating database: ". mysql_error(); } mysql_select_db(“first_DB", $con);

$sql = "CREATE TABLE students ( FirstName varchar(15), LastName varchar(15), UID int )"; // Execute query mysql_query($sql,$con); mysql_close($con); ?>

Insert Data Into a Database Table The INSERT INTO statement is used to add new records to a database table. Syntax INSERT INTO table_name VALUES (value1, value2, value3,...) Now, we will insert some data to the table that we created: <?php $con = mysql_connect("localhost",“moh",“1414"); if (!$con) { die('Could not connect: '. mysql_error()); } mysql_select_db(“first_DB", $con); mysql_query("INSERT INTO students(FirstName, LastName, UID) VALUES (‘Ali', ‘Alnashri',430444)"); mysql_query("INSERT INTO students(FirstName, LastName, UID) VALUES (‘Khalid', ‘Alqahtani',430777)"); mysql_close($con); ?>

Select data from database table Select Data From a Database Table The SELECT statement is used to select data from a database. Syntax SELECT column_name(s) FROM table_name <?php $con = mysql_connect("localhost",“moh",“1414"); if (!$con) { die('Could not connect: '. mysql_error()); } mysql_select_db(“first_DB", $con); $result = mysql_query("SELECT * FROM students"); while($row = mysql_fetch_array($result)) { echo $row['FirstName']. " ". $row['LastName']. " ". $row[‘UID'] ; echo " "; } mysql_close($con); ?>