0% found this document useful (0 votes)
29 views

UQC103S1 UFCE47-20-1: Systems Development

This document provides an introduction and crash course on PHP and mySQL. It discusses what mySQL is, why PHP is often used with mySQL as part of the LAMP stack, and how to install PHP and mySQL. It then covers basic SQL commands like creating databases and tables, inserting and selecting data. Finally, it shows examples of using PHP to connect to a mySQL database and execute queries to retrieve and display data from tables.

Uploaded by

Anirudh Kejriwal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

UQC103S1 UFCE47-20-1: Systems Development

This document provides an introduction and crash course on PHP and mySQL. It discusses what mySQL is, why PHP is often used with mySQL as part of the LAMP stack, and how to install PHP and mySQL. It then covers basic SQL commands like creating databases and tables, inserting and selecting data. Finally, it shows examples of using PHP to connect to a mySQL database and execute queries to retrieve and display data from tables.

Uploaded by

Anirudh Kejriwal
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

UQC103S1 UFCE47-20-1

Systems Development

uqc103s/UFCE47-20-1 PHP-mySQL

Who?
Email: [email protected] Web Site www.cems.uwe.ac.uk/~jedawson www.cems.uwe.ac.uk/~jtwebb/uqc103s1/
uqc103s/UFCE47-20-1 PHP-mySQL 2

HELP is at HAND

uqc103s/UFCE47-20-1 PHP-mySQL

PHP and mySQL A crash course

In this lecture we will consider:


What is mySQL? Why PHP and mySQL? How to get and install PHP/mySQL Some SQL

Using mySQL (command line)

Using PHP and mySQL


uqc103s/UFCE47-20-1 PHP-mySQL 4

What is mySQL?

The Worlds Most Popular Open Source Database


more than 4 million active installations Supports a database and allow client/server interactions (storing and retrieving information) On a large system a computer may be solely dedicated to running the DBMS

A DBMS - Database Management System

A DBA (DataBase Administrator) usually manages the database Usually a DBMS is very expensive to buy and/or maintain.

uqc103s/UFCE47-20-1 PHP-mySQL

mySQL has

Speed - written in C/C++, multithreaded,optimised Full data set - supports:

float,double, enum, date, char, varchar etc.. select, insert, delete, show, "aliases" etc

Full Command set (SQL92 compliant)

Functions - e.g. avg(), sum(), max() Security - privilege and password system Scalable - can take billions of rows of data Large character set for internationalisation Tools - admin and other access
uqc103s/UFCE47-20-1 PHP-mySQL 6

Why PHP and mySQL

MySQL is a key part of LAMP (Linux, Apache, MySQL, PHP / Perl / Python), a fast growing open source enterprise software stack. More and more companies are using LAMP as an alternative to expensive proprietary software stacks because of its lower cost and freedom from lock-in.
http://www.mysql.com/company/index.html

uqc103s/UFCE47-20-1 PHP-mySQL

How to get and install PHP/mySQL


MySQL

NOTE: In Apache users web pages are in install_dir\htdocs

http://www.mysql.com/downloads/index.html

But dont forget (mini -XAMPP) !! Apache/mySQL/PHP/Perl - download and install instructions (the "old" method should work OK)

http://www.apachefriends.org/xampp-windows-en.html mini-xampp download is about 13 Mb

uqc103s/UFCE47-20-1 PHP-mySQL

Starting Apache and mySQL


Scripts to start and stop are in the minixampp install directory Starting Apache starts an HTTP service on port 80 (default)

http://localhost/ or http://127.0.0.1/
NOTE: XAMPP contains a good admin tool for mySQL http://localhost/phpmyadmin/

Starting mySQL starts a service on port 3066 (default)


Apache (minixampp) users web pages are in: install_dir\htdocs

uqc103s/UFCE47-20-1 PHP-mySQL

Stopping and Starting

uqc103s/UFCE47-20-1 PHP-mySQL

10

Basic SQL

SQL - Structured Query Language

"sequel" or "ess-cue-el" creating a database creating a table populating a table (inserting data) viewing a table (selecting data and ordering it) changing data (updating data) deleting data

We will consider:

uqc103s/UFCE47-20-1 PHP-mySQL

11

Using SQL with mySQL


In the simplest case can use mySQL "on the command line" (DOS prompt) the command to use mysql :

install_dir\mysql\bin\mysql get a command prompt and change to the bin folder (or add mysql to your path) make sure mysql service has been started type "mysql" on the command line

uqc103s/UFCE47-20-1 PHP-mySQL

12

Connecting to mySQL creating a database and a table

uqc103s/UFCE47-20-1 PHP-mySQL

13

Populating a table Viewing contents

uqc103s/UFCE47-20-1 PHP-mySQL

14

More about select

uqc103s/UFCE47-20-1 PHP-mySQL

15

Changing and Deleting Data

uqc103s/UFCE47-20-1 PHP-mySQL

16

Using mySQL with PHP

Example One:

connect to mySQL select a database define a query execute query present results free resources

Program - mysql1.php

uqc103s/UFCE47-20-1 PHP-mySQL

17

PHP/mySQL - column headings

We can add a bit more detail:


improved formatting order by in select insert new data adding column names LINK: mysql2.php

uqc103s/UFCE47-20-1 PHP-mySQL

18

Using PHP with HTML forms The form

PHP is commonly used to process HTML forms

cf. CGI programs

See search1.html

uqc103s/UFCE47-20-1 PHP-mySQL

19

The PHP

Check input is OK connect to database run query check output process as before See: form1.php

uqc103s/UFCE47-20-1 PHP-mySQL

20

Some Helpful URLs

mySQL - reference and tutorial


http://www.mysql.com/doc/en/Introduction.htmlPHP/mySQL tutorial http://www.mysql.com/doc/en/Tutorial.html http://hotwired.lycos.com/webmonkey/99/21/index2a.html?t w=programming http://www.w3schools.com/sql/default.asp http://www.w3schools.com/php/php_db_odbc.asp

PHP/mySQL tutorial

Learn SQL

PHP to MS Access (ODBC) example

uqc103s/UFCE47-20-1 PHP-mySQL

21

You might also like