Presentation is loading. Please wait.

Presentation is loading. Please wait.

Introduction to PHP and MySQL – Creating Database-Driven Websites

Similar presentations


Presentation on theme: "Introduction to PHP and MySQL – Creating Database-Driven Websites"— Presentation transcript:

1 Introduction to PHP and MySQL – Creating Database-Driven Websites - Using WAMP

2 Introduction to PHP and MySQL – Creating Database-Driven Websites
Connecting to MySQL database on your WAMP Web Server Start / Run.. Enter mysql –h localhost –u root –p There is no password set by default on WAMP Server. Do NOT set a password.

3 Introduction to PHP and MySQL – Creating Database-Driven Websites
Connecting to MySQL database on your WAMP Web Server Start / Run.. Enter mysql –h localhost –u root –p Or Access the command line interface using WAMP’s pop-up menu

4 Introduction to PHP and MySQL – Creating Database-Driven Websites
MySQL commands: Show databases; Use database-name; Explain table-name; or describe table-name;

5 Introduction to PHP and MySQL – Creating Database-Driven Websites
MySQL commands: Create database garage; Show databases; Use garage; Create table cars(id int, make text, model text); Describe cars; Drop table cars;

6 Introduction to PHP and MySQL – Creating Database-Driven Websites
MySQL commands: Create table cars (id int auto_increment, make varchar(20) not null, model varchar(20) not null unique, primary key (id) ); Explain cars; Insert into cars values (1, “Porsche”, “Carrera”); Select * from cars; Insert into cars (make, model) values (“Ferrari”, “Dino”), (“Lamborghini”, “Diablo”);

7 Introduction to PHP and MySQL – Creating Database-Driven Websites
MySQL commands: Alter table cars add top_mph int; Select * from cars; Update cars set model = “911 Turbo” where id=1; Update cars set model = “F355” where make=“Ferrari”;

8 Introduction to PHP and MySQL – Creating Database-Driven Websites
MySQL commands: Update cars set model = “Murcielargo” where make=“Lamborghini”; Update cars set top_mph=189 where id=1; Update cars set top_mph=183 where id=2; Update cars set top_mph=205 where id=3; Select * from cars;

9 Introduction to PHP and MySQL – Creating Database-Driven Websites
MySQL commands: Delete from cars where id = 3; Alter table cars drop top_mph; Drop table cars; Drop database garage; Select * from cars;

10 Introduction to PHP and MySQL – Creating Database-Driven Websites
Using PHPMyAdmin Create a new database BookShop Under Create New Table, enter Books Number of Fields = 6 First field: Field = Bkid, Type = INT, Index = Primary, A_I for Auto Increment.

11 Introduction to PHP and MySQL – Creating Database-Driven Websites
Add records to your table: Field Type Lengths/Values Title VARCHAR 255 Author 60 Publisher Price DECIMAL 10, 2 Category 20

12 Introduction to PHP and MySQL – Creating Database-Driven Websites
Other fields: Title Author Publisher Price Category Nightfall Asimov Bantam 5.99 Sci Fi Patriot Games Clancy Berkeley 4.95 Thriller 2010 Clarke Ballantine 3.95 Lie Down with Lions Follett Signet Mystery A Thief of Time Hillerman Harper The Fly on the Wall Hornet Flight 7.99 The Innocent Man Grisham Dell Mission of Honour

13 Using the MySQL Console
Show all tables Use the Bookshop database Show all the tables Show the Books table structure Display all Books records Display all books within the category ‘Thriller’


Download ppt "Introduction to PHP and MySQL – Creating Database-Driven Websites"

Similar presentations


Ads by Google