Upload
griffin-copeland
View
216
Download
1
Embed Size (px)
Citation preview
THE WEBMASTERS: SENG + WAVERING
On account of construction, we will be having class in room 1248 next week.
We have used variables to store information for our websites to use. How do we store information for websites to use even when people close their browsers and sign off?
Databases!Allow for persistent storage of data
Databases are a way to store information without relying on Javascript or PHP variables.
A database is a table of objects – like an spreadsheet.
Columns define attributes of an object
Each row is a separate object
SQL – Structured Query LanguageA way of talking to a database which
lets us implement CRUDCRUD – the four basic functions of
persistent storage: Create, Retrieve, Update Delete
Combine basic commands and elements to form clauses
Clauses combine to form statementsUse phpMyAdmin to work with
databaseshttp://demo.phpmyadmin.net/trunk-c
onfig/
CREATE DATABASE WebshipUSE WebshipCREATE TABLE studentsDefine columnsSELECT * FROMMany other commands!
We will still use Javascript and PHP variables – need some way to take information from database and use it to create a webpage.
Can send SQL queries to database with PHP
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
Can assign PHP variables as the results returned from MySQL queries
$variable = mysql_query("SELECT * FROM example")