Presentation (Powerpoint)

896 views
853 views

Published on

1 Comment
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total views
896
On SlideShare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
18
Comments
1
Likes
0
Embeds 0
No embeds

No notes for slide

Presentation (Powerpoint)

  1. 1. PHP and MySQL Alex Matan St. David CSS, Waterloo http://alex.matan.ca/contact http://www.WebStaffRoom.ca
  2. 2. Agenda <ul><li>Introduction </li></ul><ul><li>XAMPP </li></ul><ul><li>phpMyAdmin </li></ul><ul><li>SQL </li></ul><ul><li>Create a Database and User </li></ul><ul><li>Create a Table </li></ul><ul><li>CRUD </li></ul><ul><li>PHP Code Example </li></ul>
  3. 3. Introduction <ul><li>PHP </li></ul><ul><ul><li>PHP: Hypertext Preprocessor </li></ul></ul><ul><ul><li>HTML-embedded scripting language </li></ul></ul><ul><ul><li>Free, open-source </li></ul></ul><ul><li>Apache </li></ul><ul><ul><li>Web server </li></ul></ul><ul><ul><li>Free, open-source </li></ul></ul><ul><li>MySQL </li></ul><ul><ul><li>Database management system (DBMS)‏ </li></ul></ul><ul><ul><li>Free, Open-source </li></ul></ul><ul><li>XAMPP – easily brings them all together </li></ul>
  4. 4. XAMPP <ul><li>Single file download </li></ul><ul><li>Windows, Mac, Linux </li></ul><ul><li>10 minute installation (yes/yes/OK/I agree/Finish)‏ </li></ul><ul><li>Apache web server </li></ul><ul><li>MySQL database management system (DBMS)‏ </li></ul><ul><li>phpMyAdmin web-based database administrator </li></ul><ul><li>Can run off of a memory stick </li></ul><ul><li>Shortcut to desktop launches control panel </li></ul>
  5. 5. phpMyAdmin <ul><li>Web-based database administration tool for MySQL </li></ul><ul><li>Written in PHP </li></ul><ul><li>Allows you to manage a database without knowing any SQL </li></ul>
  6. 6. SQL <ul><li>Structured Query Language </li></ul><ul><li>English-like syntax for interacting with a database </li></ul>
  7. 7. Create a Database and User <ul><li>http://192.168.1.50/phpMyAdmin </li></ul><ul><li>Click “SQL” button on left sidebar </li></ul><ul><ul><li>CREATE DATABASE yourdatabasename; </li></ul></ul><ul><ul><li>GRANT ALL PRIVILEGES ON yourdatabasename.* TO 'yourusername'@'localhost' IDENTIFIED BY 'yourpassword'; </li></ul></ul><ul><li>Click “Go.” </li></ul><ul><li>“ Your SQL query has been executed successfully” </li></ul>
  8. 8. Create a Table <ul><li>Click on yourdatabasename on leftside </li></ul><ul><li>Create a new table called students with 5 fields </li></ul><ul><ul><li>id, INT, auto_increment, primary key </li></ul></ul><ul><ul><li>firstname, varchar, 50 </li></ul></ul><ul><ul><li>lastname, varchar, 50 </li></ul></ul><ul><ul><li>city, varchar, 50 </li></ul></ul><ul><ul><li>start, datetime </li></ul></ul><ul><li>Click “Go” </li></ul><ul><ul><li>CREATE TABLE `test1`.`students` ( `id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY , `firstname` VARCHAR( 50 ) NOT NULL , `lastname` VARCHAR( 50 ) NOT NULL , `city` VARCHAR( 50 ) NOT NULL , `start` DATETIME NOT NULL ) ENGINE = MYISAM </li></ul></ul>
  9. 9. CRUD <ul><li>Create, Read, Update, Destroy </li></ul><ul><li>The basic operations that you can perform on any database table. </li></ul><ul><li>Create record(s)‏ </li></ul><ul><li>Read record(s)‏ </li></ul><ul><li>Update record(s)‏ </li></ul><ul><li>Delete record(s)‏ </li></ul>
  10. 10. CRUD - Create <ul><li>Create </li></ul><ul><ul><li>Insert a row into a table </li></ul></ul><ul><ul><li>INSERT INTO students (firstname, lastname, city) VALUES('Alex', 'Matan', 'Waterloo' )‏ </li></ul></ul>
  11. 11. CRUD - READ <ul><li>Read </li></ul><ul><li>Get all rows in a table </li></ul><ul><ul><ul><li>SELECT * FROM students </li></ul></ul></ul><ul><li>Get only rows where firstname='bob' </li></ul><ul><ul><ul><li>SELECT * FROM students WHERE firstname='Alex' </li></ul></ul></ul><ul><li>Get only rows where firstname include the string 'ba' </li></ul><ul><ul><ul><li>SELECT * FROM students WHERE firstname LIKE '%le%' </li></ul></ul></ul>
  12. 12. CRUD – Update and Delete <ul><li>Update </li></ul><ul><ul><li>UPDATE students SET firstname='Al' WHERE id='1' </li></ul></ul><ul><li>Delete </li></ul><ul><ul><li>DELETE FROM students WHERE lastname='Matan' </li></ul></ul>
  13. 13. PHP Code Example <ul><li>Konqueror </li></ul><ul><ul><li>smb://192.168.1.50 </li></ul></ul><ul><li>Create your own folder called lastname </li></ul><ul><li>Open another Konqueror </li></ul><ul><ul><li>http://192.168.1.50/lastname </li></ul></ul>
  14. 14. Thank You <ul><li>Questions? </li></ul>

×