APLIKACJE INTERNETOWE 8 PHP WYKORZYSTANIE BAZY DANYCH MYSQL

Size: px
Start display at page:

Download "APLIKACJE INTERNETOWE 8 PHP WYKORZYSTANIE BAZY DANYCH MYSQL"

Transcription

1 APLIKACJE INTERNETOWE 8 PHP WYKORZYSTANIE BAZY DANYCH MYSQL

2 PLAN PREZENTACJI Bazy danych w PHP Połączenie z bazą danych Zamknięcie połączenie Tworzenie bazy danych Tworzenie tabeli Operacje na tabelach Wstawianie nowego rekordu Kasowanie rekordu Aktualizacja rekordu Wyświetlanie rekordów

3 PODŁĄCZENIE DO BAZY DANYCH $servername = "localhost"; $username = "username"; $password = "password"; MySQLi Object-Oriented // Create connection $conn = new mysqli($servername, $username, $password); // Check connection if ($conn->connect_error) { die("connection failed: ". $conn->connect_error); echo "Connected successfully";

4 PODŁĄCZENIE DO BAZY DANYCH MySQLi Procedural // Create connection $conn = mysqli_connect($servername, $username, $password); // Check connection if (!$conn) { die("connection failed: ". mysqli_connect_error()); echo "Connected successfully";

5 PODŁĄCZENIE DO BAZY DANYCH PDO - PHP Data Objects try { $conn = new PDO("mysql:host=$servername;dbname=myDB", $username, $password); // set the PDO error mode to exception $conn->setattribute(pdo::attr_errmode, PDO::ERRMODE_EXCEPTION); echo "Connected successfully"; catch(pdoexception $e) { echo "Connection failed: ". $e->getmessage();

6 ZAMKNIĘCIE POŁĄCZENIA DO BAZY DANYCH MySQLi Object-Oriented $conn->close(); MySQLi Procedural mysqli_close($conn); PDO - PHP Data Objects $conn = null;

7 TWORZENIE BAZY DANYCH MySQLi Object-Oriented $sql = "CREATE DATABASE mydb"; if ($conn->query($sql) === TRUE) { echo "Database created successfully"; else { echo "Error creating database: ". $conn->error;

8 TWORZENIE BAZY DANYCH MySQLi Procedural $sql = "CREATE DATABASE mydb"; if (mysqli_query($conn, $sql)) { echo "Database created successfully"; else { echo "Error creating database: ". mysqli_error($conn);

9 TWORZENIE BAZY DANYCH PDO - PHP Data Objects try { $conn = new PDO("mysql:host=$servername;dbname=myDB", $username, $password); $conn->setattribute(pdo::attr_errmode, PDO::ERRMODE_EXCEPTION); $sql = "CREATE DATABASE mydbpdo"; $conn->exec($sql); echo "Database created successfully<br>"; catch(pdoexception $e) { echo $sql. "<br>". $e->getmessage();

10 TWORZENIE TABELI MySQL CREATE TABLE MyGuests ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, firstname VARCHAR(30) NOT NULL, lastname VARCHAR(30) NOT NULL, VARCHAR(50), reg_date TIMESTAMP )

11 TWORZENIE TABELI MySQLi Object-Oriented $sql = "CREATE TABLE MyGuests ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, firstname VARCHAR(30) NOT NULL, lastname VARCHAR(30) NOT NULL, VARCHAR(50), reg_date TIMESTAMP )"; if ($conn->query($sql) === TRUE) { echo "Table MyGuests created successfully"; else { echo "Error creating table: ". $conn->error;

12 TWORZENIE TABELI MySQLi Procedural $sql = "CREATE TABLE MyGuests ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, firstname VARCHAR(30) NOT NULL, lastname VARCHAR(30) NOT NULL, VARCHAR(50), reg_date TIMESTAMP )"; if (mysqli_query($conn, $sql)) { echo "Table MyGuests created successfully"; else { echo "Error creating table: ". mysqli_error($conn);

13 TWORZENIE TABELI PDO - PHP Data Objects $sql = "CREATE TABLE MyGuests ( id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY, firstname VARCHAR(30) NOT NULL, lastname VARCHAR(30) NOT NULL, VARCHAR(50), reg_date TIMESTAMP )"; // use exec() because no results are returned $conn->exec($sql); echo "Table MyGuests created successfully";

14 DODANIE REKORDU DO TABELI MySQL INSERT INTO table_name (column1, column2, column3,...) VALUES (value1, value2, value3,...)

15 DODANIE REKORDU DO TABELI MySQLi Object-Oriented $dbname = "mydb"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn->connect_error) { die("connection failed: ". $conn->connect_error); $sql = "INSERT INTO MyGuests (firstname, lastname, ) VALUES ('John', 'Doe', 'john@example.com')";

16 DODANIE REKORDU DO TABELI MySQLi Procedural $dbname = "mydb"; // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection if (!$conn) { die("connection failed: ". mysqli_connect_error()); $sql = "INSERT INTO MyGuests (firstname, lastname, ) VALUES ('John', 'Doe', 'john@example.com')";

17 DODANIE REKORDU DO TABELI PDO - PHP Data Objects $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password); // set the PDO error mode to exception $conn->setattribute(pdo::attr_errmode, PDO::ERRMODE_EXCEPTION); $sql = "INSERT INTO MyGuests (firstname, lastname, ) VALUES ('John', 'Doe', 'john@example.com')"; // use exec() because no results are returned $conn->exec($sql); echo "New record created successfully";

18 DODANIE WIELU REKORDÓW DO TABELI MySQLi Object-Oriented $sql = "INSERT INTO MyGuests (firstname, lastname, ) VALUES ('John', 'Doe', 'john@example.com');"; $sql.= "INSERT INTO MyGuests (firstname, lastname, ) VALUES ('Mary', 'Moe', 'mary@example.com');"; $sql.= "INSERT INTO MyGuests (firstname, lastname, ) VALUES ('Julie', 'Dooley', 'julie@example.com')"; if ($conn->multi_query($sql) === TRUE) { echo "New records created successfully"; else { echo "Error: ". $sql. "<br>". $conn->error;

19 DODANIE WIELU REKORDÓW DO TABELI MySQLi Procedural $sql = "INSERT INTO MyGuests (firstname, lastname, ) VALUES ('John', 'Doe', 'john@example.com');"; $sql.= "INSERT INTO MyGuests (firstname, lastname, ) VALUES ('Mary', 'Moe', 'mary@example.com');"; $sql.= "INSERT INTO MyGuests (firstname, lastname, ) VALUES ('Julie', 'Dooley', 'julie@example.com')"; if (mysqli_multi_query($conn, $sql)) { echo "New records created successfully"; else { echo "Error: ". $sql. "<br>". mysqli_error($conn);

20 DODANIE WIELU REKORDÓW DO TABELI PDO - PHP Data Objects try {... $conn->begintransaction(); $conn->exec("insert INTO MyGuests (firstname, lastname, ) VALUES ('John', 'Doe', 'john@example.com')"); $conn->exec("insert INTO MyGuests (firstname, lastname, ) VALUES ('Mary', 'Moe', 'mary@example.com')"); $conn->exec("insert INTO MyGuests (firstname, lastname, ) VALUES ('Julie', 'Dooley', 'julie@example.com')"); $conn->commit(); // commit the transaction echo "New records created successfully"; catch(pdoexception $e) { $conn->rollback(); echo "Error: ". $e->getmessage();

21 WYŚWIETLANIE ELEMENTÓW TABLICY MySQL Wyświetlane danych z danej kolumny SELECT column_name(s) FROM table_name Wyświetlanie wszystkich danych SELECT * FROM table_name

22 WYŚWIETLANIE ELEMENTÓW TABLICY MySQLi Object-Oriented $sql = "SELECT id, firstname, lastname FROM MyGuests"; $result = $conn->query($sql); if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { else { echo "id: ". $row["id"]. " - Name: ". $row["firstname"]. " ". $row["lastname"]. "<br>"; echo "0 results";

23 WYŚWIETLANIE ELEMENTÓW TABLICY MySQLi Procedural $sql = "SELECT id, firstname, lastname FROM MyGuests"; $result = mysqli_query($conn, $sql); if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_assoc($result)) { else { echo "id: ". $row["id"]. " - Name: ". $row["firstname"]. " ". $row["lastname"]. "<br>"; echo "0 results";

24 WYŚWIETLANIE ELEMENTÓW TABLICY PDO - PHP Data Objects $sql = "SELECT id, firstname, lastname FROM MyGuests"; $result = $conn->query($sql); if ($result->num_rows > 0) { echo "<table><tr><th>id</th><th>name</th></tr>"; while($row = $result->fetch_assoc()) { echo "<tr><td>".$row["id"]."</td><td>". $row["firstname"]." ".$row["lastname"]."</td></tr>"; echo "</table>"; else { echo "0 results";

25 KASOWANIE REKORDÓW Z TABELI MySQL DELETE FROM table_name WHERE some_column = some_value

26 KASOWANIE REKORDÓW Z TABELI MySQLi Object-Oriented $sql = "DELETE FROM MyGuests WHERE id=3"; if ($conn->query($sql) === TRUE) { echo "Record deleted successfully"; else { echo "Error deleting record: ". $conn->error;

27 KASOWANIE REKORDÓW Z TABELI MySQLi Procedural $sql = "DELETE FROM MyGuests WHERE id=3"; if (mysqli_query($conn, $sql)) { echo "Record deleted successfully"; else { echo "Error deleting record: ". mysqli_error($conn);

28 KASOWANIE REKORDÓW Z TABELI PDO - PHP Data Objects $sql = "DELETE FROM MyGuests WHERE id=3"; // use exec() because no results are returned $conn->exec($sql); echo "Record deleted successfully";

29 AKTUALIZACJA REKORDU TABELI MySQL UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value

30 AKTUALIZACJA REKORDU TABELI MySQLi Object-Oriented $sql = "UPDATE MyGuests SET lastname='doe' WHERE id=2"; if ($conn->query($sql) === TRUE) { echo "Record updated successfully"; else { echo "Error updating record: ". $conn->error;

31 AKTUALIZACJA REKORDU TABELI MySQLi Procedural $sql = "UPDATE MyGuests SET lastname='doe' WHERE id=2"; if (mysqli_query($conn, $sql)) { echo "Record updated successfully"; else { echo "Error updating record: ". mysqli_error($conn);

32 AKTUALIZACJA REKORDU TABELI PDO - PHP Data Objects $sql = "UPDATE MyGuests SET lastname='doe' WHERE id=2"; $stmt = $conn->prepare($sql); $stmt->execute(); echo $stmt->rowcount(). " records UPDATED successfully";

Networks and Web for Health Informatics (HINF 6220) Tutorial 13 : PHP 29 Oct 2015

Networks and Web for Health Informatics (HINF 6220) Tutorial 13 : PHP 29 Oct 2015 Networks and Web for Health Informatics (HINF 6220) Tutorial 13 : PHP 29 Oct 2015 PHP Arrays o Arrays are single variables that store multiple values at the same time! o Consider having a list of values

More information

Greetings West Ada Comp Sci TAC & Friends,

Greetings West Ada Comp Sci TAC & Friends, Greetings West Ada Comp Sci TAC & Friends, Thank you for taking time from your busy schedules to attend our Technical Advisors Meeting (TAC) last Wed: Two teachers, five industry reps. Your inputs directly

More information

PHP Development - Introduction

PHP Development - Introduction PHP Development - Introduction Php Hypertext Processor PHP stands for PHP: Hypertext Preprocessor PHP is a server-side scripting language, like ASP PHP scripts are executed on the server PHP supports many

More information

Overview of MySQL Structure and Syntax [2]

Overview of MySQL Structure and Syntax [2] PHP PHP MySQL Database Overview of MySQL Structure and Syntax [2] MySQL is a relational database system, which basically means that it can store bits of information in separate areas and link those areas

More information

AN INTRODUCTION TO WEB PROGRAMMING. Dr. Hossein Hakimzadeh Department of Computer and Information Sciences Indiana University South Bend, IN

AN INTRODUCTION TO WEB PROGRAMMING. Dr. Hossein Hakimzadeh Department of Computer and Information Sciences Indiana University South Bend, IN AN INTRODUCTION TO WEB PROGRAMMING Dr. Hossein Hakimzadeh Department of Computer and Information Sciences Indiana University South Bend, IN HISTORY Developed by Michael Widenius. Initially release in 1995.

More information

Princess Nourah bint Abdulrahman University. Computer Sciences Department

Princess Nourah bint Abdulrahman University. Computer Sciences Department Princess Nourah bint Abdulrahman University Computer Sciences Department 1 And use http://www.w3schools.com/ PHP Part 3 Objectives Creating a new MySQL Database using Create & Check connection with Database

More information

Professional PHP for working with MySQL

Professional PHP for working with MySQL Chapter 19 Professional PHP for working with MySQL PDO (PHP Data Objects) Pros Is included with PHP 5.1 and later and available for 5.0. Provides an object-oriented interface. Provides a consistent interface

More information

Advanced Web Programming Practice Exam II

Advanced Web Programming Practice Exam II Advanced Web Programming Practice Exam II Name: 12 December 2017 This is a closed book exam. You may use one sheet of notes (8.5X11in, front only) but cannot use any other references or electronic device.

More information

What is MySQL? [Document provides the fundamental operations of PHP-MySQL connectivity]

What is MySQL? [Document provides the fundamental operations of PHP-MySQL connectivity] What is MySQL? [Document provides the fundamental operations of PHP-MySQL connectivity] MySQL is a database. A database defines a structure for storing information. In a database, there are tables. Just

More information

Web Systems Nov. 2, 2017

Web Systems Nov. 2, 2017 Web Systems Nov. 2, 2017 Topics of Discussion Using MySQL as a Calculator Command Line: Create a Database, a Table, Insert Values into Table, Query Database Using PhP API to Interact with MySQL o Check_connection.php

More information

4) PHP and MySQL. Emmanuel Benoist. Spring Term Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 1

4) PHP and MySQL. Emmanuel Benoist. Spring Term Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 1 4) PHP and MySQL Emmanuel Benoist Spring Term 2017 Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 1 PHP and MySQL Introduction Basics of MySQL Create a Table See

More information

Chapters 10 & 11 PHP AND MYSQL

Chapters 10 & 11 PHP AND MYSQL Chapters 10 & 11 PHP AND MYSQL Getting Started The database for a Web app would be created before accessing it from the web. Complete the design and create the tables independently. Use phpmyadmin, for

More information

Web Programming. Dr Walid M. Aly. Lecture 10 PHP. lec10. Web Programming CS433/CS614 22:32. Dr Walid M. Aly

Web Programming. Dr Walid M. Aly. Lecture 10 PHP. lec10. Web Programming CS433/CS614 22:32. Dr Walid M. Aly Web Programming Lecture 10 PHP 1 Purpose of Server-Side Scripting database access Web page can serve as front-end to a database Ømake requests from browser, Øpassed on to Web server, Øcalls a program to

More information

Database Connectivity using PHP Some Points to Remember:

Database Connectivity using PHP Some Points to Remember: Database Connectivity using PHP Some Points to Remember: 1. PHP has a boolean datatype which can have 2 values: true or false. However, in PHP, the number 0 (zero) is also considered as equivalent to False.

More information

LAMP Apps. Overview. Learning Outcomes: At the completion of the lab you should be able to:

LAMP Apps. Overview. Learning Outcomes: At the completion of the lab you should be able to: LAMP Apps Overview This lab walks you through using Linux, Apache, MySQL and PHP (LAMP) to create simple, yet very powerful PHP applications connected to a MySQL database. For developers using Windows,

More information

Lecture 13: MySQL and PHP. Monday, March 26, 2018

Lecture 13: MySQL and PHP. Monday, March 26, 2018 Lecture 13: MySQL and PHP Monday, March 26, 2018 MySQL The Old Way In older versions of PHP, we typically used functions that started with mysql_ that did not belong to a class For example: o o o o mysql_connect()

More information

LAB 11 WORKING WITH DATABASES

LAB 11 WORKING WITH DATABASES LAB 11 WORKING WITH DATABASES What You Will Learn How to install and manage a MySQL database How to use SQL queries in you PHP code How to integrate user inputs into SQL queries How to manage files inside

More information

The M in LAMP: MySQL CSCI 470: Web Science Keith Vertanen Copyright 2014

The M in LAMP: MySQL CSCI 470: Web Science Keith Vertanen Copyright 2014 The M in LAMP: MySQL CSCI 470: Web Science Keith Vertanen Copyright 2014 MySQL Setup, using console Data types Overview Creating users, databases and tables SQL queries INSERT, SELECT, DELETE WHERE, ORDER

More information

SQL stands for Structured Query Language. SQL lets you access and manipulate databases

SQL stands for Structured Query Language. SQL lets you access and manipulate databases CMPSC 117: WEB DEVELOPMENT SQL stands for Structured Query Language SQL lets you access and manipulate databases SQL is an ANSI (American National Standards Institute) standard 1 SQL can execute queries

More information

MULTIMEDIA AND WEB TECHNOLOGY

MULTIMEDIA AND WEB TECHNOLOGY SET 4 Series : GBM/1 Code No. 89/1 Roll No. Candidates must write the Code on the title page of the answer-book. Please check that this question paper contains 08 printed pages. Code number given on the

More information

Multimedia im Netz Online Multimedia Winter semester 2015/16

Multimedia im Netz Online Multimedia Winter semester 2015/16 Multimedia im Netz Online Multimedia Winter semester 2015/16 Tutorial 05 Minor Subject Ludwig-Maximilians-Universität München Online Multimedia WS 2015/16 - Tutorial 05 (NF) - 1 Today s Agenda Discussion

More information

Chapter 10: MySQL & PHP. PHP and MySQL CIS 86 Mission College

Chapter 10: MySQL & PHP. PHP and MySQL CIS 86 Mission College Chapter 10: MySQL & PHP PHP and MySQL CIS 86 Mission College Tonight s agenda Drop the class? Login file Connecting to a MySQL database Object-oriented PHP Executing a query Fetching a result Fetching

More information

Using PHP with MYSQL

Using PHP with MYSQL Using PHP with MYSQL PHP & MYSQL So far you've learned the theory behind relational databases and worked directly with MySQL through the mysql command-line tool. Now it's time to get your PHP scripts talking

More information

MULTIMEDIA AND WEB TECHNOLOGY

MULTIMEDIA AND WEB TECHNOLOGY SET-4 Series GBM Code No. 89 Roll No. Candidates must write the Code on the title page of the answer-book. Please check that this question paper contains 9 printed pages. Code number given on the right

More information

MySQL: Access Via PHP

MySQL: Access Via PHP MySQL: Access Via PHP CISC 282 November 15, 2017 phpmyadmin: Login http://cisc282.caslab. queensu.ca/phpmyadmin/ Use your NetID and CISC 282 password to log in 2 phpmyadmin: Select DB Clicking on this

More information

Chapter 7 PHP Files & MySQL Databases

Chapter 7 PHP Files & MySQL Databases Chapter 7 PHP Files & MySQL Databases At the end of the previous chapter, a simple calendar was displayed with an appointment. This demonstrated again how forms can be used to pass data from one page to

More information

CPET 499/ITC 250 Web Systems. Topics

CPET 499/ITC 250 Web Systems. Topics CPET 499/ITC 250 Web Systems Chapter 14 Web Application Design Text Book: * Fundamentals of Web Development, 2015, by Randy Connolly and Ricardo Hoar, published by Pearson Paul I-Hai, Professor of Electrical

More information

CPET 499/ITC 250 Web Systems

CPET 499/ITC 250 Web Systems CPET 499/ITC 250 Web Systems Chapter 11 Working with Databases Part 2 of 3 Text Book: * Fundamentals of Web Development, 2015, by Randy Connolly and Ricardo Hoar, published by Pearson Paul I-Hai, Professor

More information

APPENDIX. dbskripsi.sql CREATE DATABASE drop database if exists dbskripsi; create database dbskripsi; use dbskripsi;

APPENDIX. dbskripsi.sql CREATE DATABASE drop database if exists dbskripsi; create database dbskripsi; use dbskripsi; APPENDIX dbskripsi.sql CREATE DATABASE drop database if exists dbskripsi; create database dbskripsi; use dbskripsi; PROCEDURE CREATE TABLES delimiter $$ create procedure spfirsttimerunning() begin drop

More information

escuela técnica superior de ingeniería informática

escuela técnica superior de ingeniería informática Tiempo: 2h escuela técnica superior de ingeniería informática Versión original: José Antonio Parejo y Manuel Resinas (diciembre 2008) Última revisión: Amador Durán y David Benavides (diciembre 2006); revisión

More information

School of Information and Computer Technology Sirindhorn International Institute of Technology Thammasat University

School of Information and Computer Technology Sirindhorn International Institute of Technology Thammasat University School of Information and Computer Technology Sirindhorn International Institute of Technology Thammasat University ITS331 Information Technology Laboratory I Laboratory #8: PHP & Form Processing II Objective:

More information

School of Information and Computer Technology Sirindhorn International Institute of Technology Thammasat University

School of Information and Computer Technology Sirindhorn International Institute of Technology Thammasat University School of Information and Computer Technology Sirindhorn International Institute of Technology Thammasat University ITS351 Database Programming Laboratory Laboratory #9: PHP & Form Processing III Objective:

More information

What is MySQL? PHP Penn Wu, PhD 323. SELECT FROM Orders WHERE Amount > 200; Client browser. MySQL server. Apache server.

What is MySQL? PHP Penn Wu, PhD 323. SELECT FROM Orders WHERE Amount > 200; Client browser. MySQL server. Apache server. Lecture #12 Introduction PHP and MySQL (MariaDB) PHP and MySQL is probably the most popular combination for building data-driven web sites. While PHP is a scripting language for building dynamic web applications,

More information

PHP: Cookies, Sessions, Databases. CS174. Chris Pollett. Sep 24, 2008.

PHP: Cookies, Sessions, Databases. CS174. Chris Pollett. Sep 24, 2008. PHP: Cookies, Sessions, Databases. CS174. Chris Pollett. Sep 24, 2008. Outline. How cookies work. Cookies in PHP. Sessions. Databases. Cookies. Sometimes it is useful to remember a client when it comes

More information

PHP Querying. Lecture 21. Robb T. Koether. Hampden-Sydney College. Fri, Mar 2, 2018

PHP Querying. Lecture 21. Robb T. Koether. Hampden-Sydney College. Fri, Mar 2, 2018 PHP Querying Lecture 21 Robb T. Koether Hampden-Sydney College Fri, Mar 2, 2018 Robb T. Koether (Hampden-Sydney College) PHP Querying Fri, Mar 2, 2018 1 / 32 1 Connect to the Database 2 Querying the Database

More information

COMP519: Web Programming Autumn 2015

COMP519: Web Programming Autumn 2015 COMP519: Web Programming Autumn 2015 In the next lectures you will learn What is SQL How to access mysql database How to create a basic mysql database How to use some basic queries How to use PHP and mysql

More information

AirAsia E-Concierge Progression Report. 1.0 Connect to Database

AirAsia E-Concierge Progression Report. 1.0 Connect to Database 1.0 Connect to Database To communicate with database, we created a php file to allow the website communicate with the database. After fetching data from URL, it will create a server communication with

More information

DATABASE MANAGEMENT SYSTEMS

DATABASE MANAGEMENT SYSTEMS DATABASE MANAGEMENT SYSTEMS Associate Professor Dr. Raed Ibraheem Hamed University of Human Development, College of Science and Technology Departments of IT and Computer Science 2015 2016 1 The ALTER TABLE

More information

A340 Laboratory Session #17

A340 Laboratory Session #17 A340 Laboratory Session #17 LAB GOALS Interacting with MySQL PHP Classes and Objects (Constructors, Destructors, Instantiation, public, private, protected,..) Step 1: Start with creating a simple database

More information

Databases and PHP. Accessing databases from PHP

Databases and PHP. Accessing databases from PHP Databases and PHP Accessing databases from PHP PHP & Databases PHP can connect to virtuay any database There are specific functions buit-into PHP to connect with some DB There is aso generic ODBC functions

More information

If Only. More SQL and PHP

If Only. More SQL and PHP If Only More SQL and PHP PHP: The if construct If only I could conditionally select PHP statements to execute. That way, I could have certain actions happen only under certain circumstances The if statement

More information

Development Technologies. Agenda: phpmyadmin 2/20/2016. phpmyadmin MySQLi. Before you can put your data into a table, that table should exist.

Development Technologies. Agenda: phpmyadmin 2/20/2016. phpmyadmin MySQLi. Before you can put your data into a table, that table should exist. CIT 736: Internet and Web Development Technologies Lecture 10 Dr. Lupiana, DM FCIM, Institute of Finance Management Semester 1, 2016 Agenda: phpmyadmin MySQLi phpmyadmin Before you can put your data into

More information

Web Application Development (WAD) V th Sem BBAITM (Unit 4) By: Binit Patel

Web Application Development (WAD) V th Sem BBAITM (Unit 4) By: Binit Patel Web Application Development (WAD) V th Sem BBAITM (Unit 4) By: Binit Patel Working with Forms: A very popular way to make a web site interactive is using HTML based forms by the site. Using HTML forms,

More information

Databases (MariaDB/MySQL) CS401, Fall 2015

Databases (MariaDB/MySQL) CS401, Fall 2015 Databases (MariaDB/MySQL) CS401, Fall 2015 Database Basics Relational Database Method of structuring data as tables associated to each other by shared attributes. Tables (kind of like a Java class) have

More information

COMP284 Scripting Languages Lecture 13: PHP (Part 5) Handouts

COMP284 Scripting Languages Lecture 13: PHP (Part 5) Handouts COMP284 Scripting Languages Lecture 13: PHP (Part 5) Handouts Ullrich Hustadt Department of Computer Science School of Electrical Engineering, Electronics, and Computer Science University of Liverpool

More information

Chapter 6 Part2: Manipulating MySQL Databases with PHP

Chapter 6 Part2: Manipulating MySQL Databases with PHP IT215 Web Programming 1 Chapter 6 Part2: Manipulating MySQL Databases with PHP Jakkrit TeCho, Ph.D. Business Information Technology (BIT), Maejo University Phrae Campus Objectives In this chapter, you

More information

A Crash Course in PDO

A Crash Course in PDO PDO (PHP Data Objects) provides a vendor-neutral method of accessing a database through PHP. This means that, once you have established a connection to the specific database, the methods used to access

More information

Unit 27 Web Server Scripting Extended Diploma in ICT

Unit 27 Web Server Scripting Extended Diploma in ICT Unit 27 Web Server Scripting Extended Diploma in ICT Dynamic Web pages Having created a few web pages with dynamic content (Browser information) we now need to create dynamic pages with information from

More information

Comp 519: Web Programming Autumn 2015

Comp 519: Web Programming Autumn 2015 Comp 519: Web Programming Autumn 2015 Advanced SQL and PHP Advanced queries Querying more than one table Searching tables to find information Aliasing tables PHP functions for using query results Using

More information

Managing Multiple Database Tables

Managing Multiple Database Tables Chapter 16 Managing Multiple Database Tables The previous chapter showed you how to use INNER JOIN and LEFT JOIN to retrieve information stored in multiple tables. You also learned how to link existing

More information

Lecture 5. Monday, September 15, 2014

Lecture 5. Monday, September 15, 2014 Lecture 5 Monday, September 15, 2014 The MySQL Command So far, we ve learned some parts of the MySQL command: mysql [database] [-u username] p [-- local-infile]! Now let s go further 1 mysqldump mysqldump

More information

PHP. M hiwa ahamad aziz Raparin univercity. 1 Web Design: Lecturer ( m hiwa ahmad aziz)

PHP. M hiwa ahamad aziz  Raparin univercity. 1 Web Design: Lecturer ( m hiwa ahmad aziz) PHP M hiwa ahamad aziz www.raparinweb.com Raparin univercity 1 Server-Side Programming language asp, asp.net, php, jsp, perl, cgi... 2 Of 68 Client-Side Scripting versus Server-Side Scripting Client-side

More information

Open Source Web Application Development - CS310

Open Source Web Application Development - CS310 2018 Open Source Web Application Development - CS310 KASHIF ADEEL bc140401362@vu.edu.pk Introduction PHP PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages.

More information

international php conference 2005 Lukas Kahwe Smith

international php conference 2005 Lukas Kahwe Smith "Relational Database Starter Day" international php conference 2005 Lukas Kahwe Smith smith@pooteeweet.org Relational Database Starter Day Agenda: Part I Getting Started Retrieving Data I Part II Data

More information

php works 2006 in Toronto Lukas Kahwe Smith

php works 2006 in Toronto Lukas Kahwe Smith Building Portable Database Applications php works 2006 in Toronto Lukas Kahwe Smith smith@pooteeweet.org Agenda: Overview Introduction ext/pdo PEAR::MDB2 ORM and ActiveRecord SQL Syntax Result Sets High

More information

Chapter 13 : Informatics Practices. Class XI ( As per CBSE Board) SQL Commands. New Syllabus Visit : python.mykvs.in for regular updates

Chapter 13 : Informatics Practices. Class XI ( As per CBSE Board) SQL Commands. New Syllabus Visit : python.mykvs.in for regular updates Chapter 13 : Informatics Practices Class XI ( As per CBSE Board) SQL Commands New Syllabus 2018-19 SQL SQL is an acronym of Structured Query Language.It is a standard language developed and used for accessing

More information

CSC System Development with Java. Database Connection. Department of Statistics and Computer Science. Budditha Hettige

CSC System Development with Java. Database Connection. Department of Statistics and Computer Science. Budditha Hettige CSC 308 2.0 System Development with Java Database Connection Budditha Hettige Department of Statistics and Computer Science Budditha Hettige 1 From database to Java There are many brands of database: Microsoft

More information

If you do not specify any custom parameters, we will deliver the message using the default names.

If you do not specify any custom parameters, we will deliver the message using the default names. Inbound SMS to UK landline numbers API HTTP GET/POST variables If you choose to have the messages delivered by HTTP, you may either use our standard parameters, or create a custom format for compatibility

More information

Introduction to SQL on GRAHAM ED ARMSTRONG SHARCNET AUGUST 2018

Introduction to SQL on GRAHAM ED ARMSTRONG SHARCNET AUGUST 2018 Introduction to SQL on GRAHAM ED ARMSTRONG SHARCNET AUGUST 2018 Background Information 2 Background Information What is a (Relational) Database 3 Dynamic collection of information. Organized into tables,

More information

Hello everyone! Page 1. Your folder should look like this. To start with Run your XAMPP app and start your Apache and MySQL.

Hello everyone! Page 1. Your folder should look like this. To start with Run your XAMPP app and start your Apache and MySQL. Hello everyone! Welcome to our PHP + MySQL (Easy to learn) E.T.L. free online course Hope you have installed your XAMPP? And you have created your forms inside the studio file in the htdocs folder using

More information

CMPS 401 Survey of Programming Languages

CMPS 401 Survey of Programming Languages CMPS 401 Survey of Programming Languages Programming Assignment #4 PHP Language On the Ubuntu Operating System Write a PHP program (P4.php) and create a HTML (P4.html) page under the Ubuntu operating system.

More information

Documentation for PHP ORMapper. version 2.0

Documentation for PHP ORMapper. version 2.0 Documentation for PHP ORMapper version 2.0 Table of Contents Licensing...3 Requirements and installation...4 The Author...4 The Classes...5 Code examples...7 Licensing This project is released under the

More information

WEB TECHNOLOGY LABORATORY WITH MINI PROJECT - 15CSL77

WEB TECHNOLOGY LABORATORY WITH MINI PROJECT - 15CSL77 - WEB TECHNOLOGY LABORATORY WITH MINI PROJECT [As per Choice Based Credit System (CBCS) scheme] (Effective from the academic year 2016-2017) SEMESTER VII Subject Code: IA Marks :20 Number of Lecture Hours/Week

More information

Working with Databases and Java

Working with Databases and Java Working with Databases and Java Pedro Contreras Department of Computer Science Royal Holloway, University of London January 30, 2008 Outline Introduction to relational databases Introduction to Structured

More information

Lab # 2 Hands-On. DDL Basic SQL Statements Institute of Computer Science, University of Tartu, Estonia

Lab # 2 Hands-On. DDL Basic SQL Statements Institute of Computer Science, University of Tartu, Estonia Lab # 2 Hands-On DDL Basic SQL Statements Institute of Computer Science, University of Tartu, Estonia Part A: Demo by Instructor in Lab a. Data type of MySQL b. CREATE table c. ALTER table (ADD, CHANGE,

More information

How to use SQL to create a database

How to use SQL to create a database Chapter 17 How to use SQL to create a database How to create a database CREATE DATABASE my_guitar_shop2; How to create a database only if it does not exist CREATE DATABASE IF NOT EXISTS my_guitar_shop2;

More information

COM1004 Web and Internet Technology

COM1004 Web and Internet Technology COM1004 Web and Internet Technology When a user submits a web form, how do we save the information to a database? How do we retrieve that data later? ID NAME EMAIL MESSAGE TIMESTAMP 1 Mike mike@dcs Hi

More information

PHP Introduction. Some info on MySQL which we will cover in the next workshop...

PHP Introduction. Some info on MySQL which we will cover in the next workshop... PHP and MYSQL PHP Introduction PHP is a recursive acronym for PHP: Hypertext Preprocessor -- It is a widely-used open source general-purpose serverside scripting language that is especially suited for

More information

Database Systems. phpmyadmin Tutorial

Database Systems. phpmyadmin Tutorial phpmyadmin Tutorial Please begin by logging into your Student Webspace. You will access the Student Webspace by logging into the Campus Common site. Go to the bottom of the page and click on the Go button

More information

IELM 511 Information Systems Design Labs 5 and 6. DB creation and Population

IELM 511 Information Systems Design Labs 5 and 6. DB creation and Population IELM 511 Information Systems Design Labs 5 and 6. DB creation and Population In this lab, your objective is to learn the basics of creating and managing a DB system. One way to interact with the DBMS (MySQL)

More information

Ark Database Documentation

Ark Database Documentation Ark Database Documentation Release 0.1.0 Liu Dong Nov 24, 2017 Contents 1 Introduction 3 1.1 What s included............................................. 3 1.2 Supported Drivers............................................

More information

2017 Politecnico di Torino 1

2017 Politecnico di Torino 1 SQL for the applications Call Level Interface Requests are sent to the DBMS through functions of the host language solution based on predefined interfaces API, Application Programming Interface SQL instructions

More information

SQL Commands & Mongo DB New Syllabus

SQL Commands & Mongo DB New Syllabus Chapter 15 : Computer Science Class XI ( As per CBSE Board) SQL Commands & Mongo DB New Syllabus 2018-19 SQL SQL is an acronym of Structured Query Language.It is a standard language developed and used

More information

2017 Politecnico di Torino 1

2017 Politecnico di Torino 1 SQL for the applications Call Level Interface Requests are sent to the DBMS through functions of the host language solution based on predefined interfaces API, Application Programming Interface SQL instructions

More information

Systems Programming & Scripting

Systems Programming & Scripting Systems Programming & Scripting Lecture 19: Database Support Sys Prog & Scripting - HW Univ 1 Typical Structure of a Web Application Client Internet Web Server Application Server Database Server Third

More information

ITS331 IT Laboratory I: (Laboratory #11) Session Handling

ITS331 IT Laboratory I: (Laboratory #11) Session Handling School of Information and Computer Technology Sirindhorn International Institute of Technology Thammasat University ITS331 Information Technology Laboratory I Laboratory #11: Session Handling Creating

More information

SQL. Often times, in order for us to build the most functional website we can, we depend on a database to store information.

SQL. Often times, in order for us to build the most functional website we can, we depend on a database to store information. Often times, in order for us to build the most functional website we can, we depend on a database to store information. If you ve ever used Microsoft Excel or Google Spreadsheets (among others), odds are

More information

October 29, Copyright 2012 by World Class CAD, LLC. All Rights Reserved.

October 29, Copyright 2012 by World Class CAD, LLC. All Rights Reserved. Create a Table with SQL October 29, 2012 Copyright 2012 by World Class CAD, LLC. All Rights Reserved. Run SQL Command Line We will begin this lesson by building a simple table. On the Start menu, select

More information

Use of PHP for DB Connection. Middle and Information Tier. Middle and Information Tier

Use of PHP for DB Connection. Middle and Information Tier. Middle and Information Tier Use of PHP for DB Connection 1 2 Middle and Information Tier PHP: built in library functions for interfacing with the mysql database management system $id = mysqli_connect(string hostname, string username,

More information

CSE 154 LECTURE 23:RELATIONAL DATABASES AND SQL

CSE 154 LECTURE 23:RELATIONAL DATABASES AND SQL CSE 154 LECTURE 23:RELATIONAL DATABASES AND SQL Relational databases relational database: A method of structuring data as tables associated to each other by shared attributes. a table row corresponds to

More information

SQL AND MORE EVENT VALIDATION

SQL AND MORE EVENT VALIDATION CSC 210 1 SQL AND MORE EVENT VALIDATION Database and front end tricks Announcements 2 Demo Tuesday, April 1 Sprint 1 n Each person chooses a story n The team presents the results to the TA n The TA grades

More information

CSC 215 PROJECT 2 DR. GODFREY C. MUGANDA

CSC 215 PROJECT 2 DR. GODFREY C. MUGANDA CSC 215 PROJECT 2 DR. GODFREY C. MUGANDA 1. Project Overview In this project, you will create a PHP web application that you can use to track your friends. Along with personal information, the application

More information

CHAPTER 10. Connecting to Databases within PHP

CHAPTER 10. Connecting to Databases within PHP CHAPTER 10 Connecting to Databases within PHP CHAPTER OBJECTIVES Get a connection to a MySQL database from within PHP Use a particular database Send a query to the database Parse the query results Check

More information

13.1 Relational Databases (continued) 13.1 Relational Databases. - Logical model

13.1 Relational Databases (continued) 13.1 Relational Databases. - Logical model 13.1 Relational Databases 13.1 Relational Databases (continued) - A relational database is a collection of tables of data, each of which has one special column that stores the primary keys of the table

More information

13.1 Relational Databases

13.1 Relational Databases 13.1 Relational Databases - A relational database is a collection of tables of data, each of which has one special column that stores the primary keys of the table - Designing a relational database for

More information

CSC Web Programming. Introduction to SQL

CSC Web Programming. Introduction to SQL CSC 242 - Web Programming Introduction to SQL SQL Statements Data Definition Language CREATE ALTER DROP Data Manipulation Language INSERT UPDATE DELETE Data Query Language SELECT SQL statements end with

More information

Module 3 MySQL Database. Database Management System

Module 3 MySQL Database. Database Management System Module 3 MySQL Database Module 3 Contains 2 components Individual Assignment Group Assignment BOTH are due on Mon, Feb 19th Read the WIKI before attempting the lab Extensible Networking Platform 1 1 -

More information

Question Bank. Class: XII. Sub: Multimedia & Web Technology (Code-067)

Question Bank. Class: XII. Sub: Multimedia & Web Technology (Code-067) Question Bank Class: XII Sub: Multimedia & Web Technology (Code-067) SECTION-1 ( COMPUTER & DATABASE SYSTEMS & OTHERS) Q1. (a) Shreya wants to work on database management software. Suggest her any two

More information

COMP 430 Intro. to Database Systems. SQL from application code

COMP 430 Intro. to Database Systems. SQL from application code COMP 430 Intro. to Database Systems SQL from application code Some issues How to connect to database Where, what type, user credentials, How to send SQL commands How to get communicate data to/from DB

More information

The connection has timed out

The connection has timed out 1 of 7 2/17/2018, 7:46 AM Mukesh Chapagain Blog PHP Magento jquery SQL Wordpress Joomla Programming & Tutorial HOME ABOUT CONTACT ADVERTISE ARCHIVES CATEGORIES MAGENTO Home» PHP PHP: CRUD (Add, Edit, Delete,

More information

Oracle Exam 1z0-882 Oracle Certified Professional, MySQL 5.6 Developer Version: 7.0 [ Total Questions: 100 ]

Oracle Exam 1z0-882 Oracle Certified Professional, MySQL 5.6 Developer Version: 7.0 [ Total Questions: 100 ] s@lm@n Oracle Exam 1z0-882 Oracle Certified Professional, MySQL 5.6 Developer Version: 7.0 [ Total Questions: 100 ] Oracle 1z0-882 : Practice Test Question No : 1 Consider the statements: Mysql> drop function

More information

Calling SQL from a host language (Java and Python) Kathleen Durant CS 3200

Calling SQL from a host language (Java and Python) Kathleen Durant CS 3200 Calling SQL from a host language (Java and Python) Kathleen Durant CS 3200 1 SQL code in other programming languages SQL commands can be called from within a host language (e.g., C++ or Java) program.

More information

Chapter. Accessing MySQL Databases Using PHP

Chapter. Accessing MySQL Databases Using PHP Chapter 12 Accessing MySQL Databases Using PHP 150 Essential PHP fast Introduction In the previous chapter we considered how to create databases using MySQL. While this is useful, it does not enable us

More information

MySQL/PHP APIs. mysql (original) mysqli (improved) PDO (preferred) API - Application Programming Interface

MySQL/PHP APIs. mysql (original) mysqli (improved) PDO (preferred) API - Application Programming Interface TU MySQL 1 MySQL/PHP APIs mysql (original) mysqli (improved) PDO (preferred) 2 API - Application Programming Interface mysql, mysqli - work only with MySQL PDO (PHP Data Object) - works with other DBs

More information

IT360: Applied Database Systems. SQL: Structured Query Language DDL and DML (w/o SELECT) (Chapter 7 in Kroenke) SQL: Data Definition Language

IT360: Applied Database Systems. SQL: Structured Query Language DDL and DML (w/o SELECT) (Chapter 7 in Kroenke) SQL: Data Definition Language IT360: Applied Database Systems SQL: Structured Query Language DDL and DML (w/o SELECT) (Chapter 7 in Kroenke) 1 Goals SQL: Data Definition Language CREATE ALTER DROP SQL: Data Manipulation Language INSERT

More information

Almost all new data created today is digital Problem: How to organize the data and store it? Capacity Speed Life of the data Number of users

Almost all new data created today is digital Problem: How to organize the data and store it? Capacity Speed Life of the data Number of users Databases Almost all new data created today is digital Problem: How to organize the data and store it? Capacity Speed Life of the data Number of users 2 Batch Processing Transactions are collected over

More information

SREE CHAITANYA COLLEGE OF ENGINEERING

SREE CHAITANYA COLLEGE OF ENGINEERING SREE CHAITANYA COLLEGE OF ENGINEERING COMPUTER SCIENCE & ENGINEERING WT LAB MANUAL ( R13 REGULATION) 1. Install the following on the local machine a. Apache Web Server b. Tomcat Application Server locally

More information

Unit IV- Server Side Technologies (PHP)

Unit IV- Server Side Technologies (PHP) Web Technology Unit IV- Server Side Technologies (PHP) By Prof. B.A.Khivsara Note: The material to prepare this presentation has been taken from internet and are generated only for students reference and

More information

Mount Saint Mary College, Newburgh, NY Internet Programming III - CIT310

Mount Saint Mary College, Newburgh, NY Internet Programming III - CIT310 Warm up mini-lab Lab 1 - Functions Type in the following function definition and calls to the function. Test it and understand it. function myprint($str= No String Supplied ) // the argument is optional

More information

COMS 469: Interactive Media II

COMS 469: Interactive Media II COMS 469: Interactive Media II Agenda Review Content Management (cont.) Replace all txt files with database tables Expand PHP/MySQL SELECT, UPDATE & DELETE queries Permit full editorial control over content

More information