Loading presentation...

Present Remotely

Send the link below via email or IM

Copy

Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.

DeleteCancel

Make your likes visible on Facebook?

Connect your Facebook account to Prezi and let your likes appear on your timeline.
You can change this under Settings & Account at any time.

No, thanks

Tutorial: Using PHP & MySQL | 46h

How to create an online application with PHP & MySQL. It'll show how to SELECT, INSERT, UPDATE and DELETE data within an application.
by

Jan Ingemansen

on 18 February 2016

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Tutorial: Using PHP & MySQL | 46h

Timeregistration App
with PHP and MySQL

Database
We will create an online application.

It will be an application to enter time registration for tasks done.

We will use:
MySQL
PHP
HTML
and a little CSS
Format Data
Input Data
Update data
Delete Data
Create User
Create Table
We use PHPMyadmin to administer our MySQL database. You can learn more here:
http://wiki.phpmyadmin.net/pma/Welcome_to_phpMyAdmin_Wiki
Create Database
Use the same databasename, username and password in your local server as in your web-hotel.

This way you can develop on your computer and then export the database and easily transfer files to your web-hotel when you are ready.
Se how on video
Step by Step
Open PHPMyAdmin
Goto Databases tab
Name database timereg
Collation utf8_general_ci
Step by Step
In PHPMyAdmin:
Goto database timereg
Click on privileges tab
Fill in username, Host: usually localhost, password
Go to bottom and click Go
collation is a set of rules used for comparison. Whitch in turn is dependent on the characterset used.
Collation in a database
http://wiki.answers.com/Q/What_is_collation_in_MySQL_Database#slide1
Tip!
Se how on video
Datatypes
There are three main types of data:
numeric
strings
date and time
http://www.tutorialspoint.com/mysql/mysql-data-types.htm
Primary Key
A primary key is needed in order to identify each record in a table.

If the table doesn't have a field with unique information, then you can combine fields in a composite key or you can create a surrogate (artificial) key.
Primary key:
http://www.w3schools.com/sql/sql_primarykey.asp
Surrogate key:
http://en.wikipedia.org/wiki/Surrogate_key
Always fill in some data in the tables.

This will help you find mistakes in your datatypes and also help when you want to test you PHP scripts.
Tip!
Create PHP File
See how on video
Use lower case letters for all names: database, table and columns.

In SQL "Timereg" is different from "timereg" so it becomes easy to make mistakes by forgetting to capitalize the first letter.
Tip!
Dowload file:
https://drive.google.com/file/d/0ByH0GmLzUOpCWWJBaW80STgta28/edit?usp=sharing
Connect to database
See how on video
http://www.w3schools.com/php/php_mysql_connect.asp
Look it up
Display your table
See how on video
Download

https://drive.google.com/file/d/0ByH0GmLzUOpCRWdhUV81U1RyZDg/edit?usp=sharing
http://www.w3schools.com/php/php_mysql_select.asp
Look it up
Download

https://drive.google.com/file/d/0ByH0GmLzUOpCV29DYUpuTDZ0SGc/edit?usp=sharing
Show Data
Format with SQL
See how on video
Look it up
Format with loops
See how on video
Look it up
Calculate with SQL
See how on video
http://www.w3resource.com/mysql/date-and-time-functions/mysql-timediff-function.php
Look it up
Download

https://drive.google.com/file/d/0ByH0GmLzUOpCTW1HUDFidHNZUEk/edit?usp=sharing
MySQL DATE_FORMAT()
http://www.w3schools.com/sql/func_date_format.asp
MySQL Aliases (AS)
http://www.w3schools.com/sql/sql_alias.asp
Use PHPMyAdmin to test your queries. You can copy them into the SQL tab in your database view.

This way you will get error messages and be able to experiament with your query!
Tip!

Download

https://drive.google.com/file/d/0ByH0GmLzUOpCbUtSREdUVWtaTk0/edit?usp=sharing
mysqli_fetch_field
http://www.w3schools.com/php/func_mysqli_fetch_field.asp
foreach loop
http://www.w3schools.com/php/php_looping_for.asp
Obejct notation ($fieldinfo->name)
http://www.phpied.com/javascript-style-object-literals-in-php/
Input Form
See how on video
<form> action Attribute
http://www.w3schools.com/tags/att_form_action.asp
Look it up
Download
https://drive.google.com/file/d/0ByH0GmLzUOpCOU1Pc093ZV82Mnc/edit?usp=sharing
<form> method Attribute
http://www.w3schools.com/tags/att_form_method.asp
PHP Include Files
http://www.w3schools.com/php/php_includes.asp
Insert Script
See how on video
PHP Functions
http://www.w3schools.com/php/php_functions.asp
Look it up
PHP Variable Scope (global/local)
http://www.w3schools.com/php/php_variables.asp
PHP Form Handling ($_POST)
http://www.w3schools.com/php/php_forms.asp
Download
https://drive.google.com/file/d/0ByH0GmLzUOpCc0hpQTE0N3pQWjg/edit?usp=sharing
SQL INSERT INTO Statement
http://www.w3schools.com/sql/sql_insert.asp
Add ID to Table
See how on video
Download
https://drive.google.com/file/d/0ByH0GmLzUOpCSFhxbXp0QzVNaDQ/edit?usp=sharing
Prefilled Form
See how on video
Download

https://drive.google.com/file/d/0ByH0GmLzUOpCTUV4TEMxOFJPSzA/edit?usp=sharing
Update Script
See how on video
Download

https://drive.google.com/file/d/0ByH0GmLzUOpCakJYTXdFOTh5Rkk/edit?usp=sharing
SQL UPDATE Statement
http://www.w3schools.com/sql/sql_update.asp
Look it up
Simple Delete
See how on video
SQL DELETE Statement
http://www.w3schools.com/sql/sql_delete.asp
Look it up
Download
https://drive.google.com/file/d/0ByH0GmLzUOpCQlRPRW9tVlhZZkE/edit?usp=sharing
Delete with Confirm
See how on video
Download
https://drive.google.com/file/d/0ByH0GmLzUOpCTEhHeDh4YzRlNjQ/edit?usp=sharing
Thank you!
You should now have a functioning PHP & MySQL application where you can SELECT, INSERT, UPDATE and DELETE data.
© Jan Ingemansen 2013
Prerequisites
In order to use this tutorial you need:

Basic knowledge of PHP programming
Very basic knowledge of MySQL databases
Very Basic knowledge of PHPMyAdmin
A local server installation (WAMP or MAMP server is perfect)
A Tutorial
The purpose is to learn how to turn basic skills in PHP and MySQL into an actual application!
Full transcript