One (Select & Delete)

Download Report

Transcript One (Select & Delete)

Introduction to
PHP and MySQL
Kirkwood Center for
Continuing Education
By Fred McClurg, [email protected]
© Copyright 2010 All Rights Reserved.
Class Project
Recipe DB Application
Part One: Search & Delete
http://webcert.kirkwood.edu/~fmccl
urg/courses/php/slides/recipe01.ppt
Requirements Definition
Description: The first step of any project is to define the
requirements.
1.
Provide a web interface to the notecard database.
2.
Make sure that the user can perform CRUD
operations on the data.
3.
Function is more important than esthetics. For this
project, we pick “fast” and “cheap”.
Good
Fast
Cheap
Database Requirements
Review: An understanding of the database schema is important.
1.
To rapidly create database and test data, import “cookbookDB.sql”
or create the following database from scratch.
Interface Design
Description: It is pretty hard to beat pencil
and paper for rapidly laying out ideas.
The original sketch can be refined using
“visio”, “dia”, “xfig”, or “OpenOffice
Draw”.
The form controls can also be captured as
images to be pasted and arranged in any
graphics application. (see
“webParts.html”)
Interface Design
Sketch of
interface that
handles the
“R” and “D”
of CRUD:
Search
Title
Recipe
Category
Jello
Mix ...
Dessert
Pudding
Mix ...
Dessert
Koolaid
Mix ...
Beverage
...
...
...
Delete?
Delete
Selected
Interface Design
Alternate
sketch of GUI
interface that
handles the
“R” and “D”
of CRUD:
Search
Title
Recipe
Category
Delete
Jello
Mix ...
Dessert
Delete
Pudding
Mix ...
Dessert
Delete
Koolaid
Mix ...
Beverage
Delete
...
...
...
Delete
Interface Design
Sketch of GUI
interface that
handles the
“C” and “U”
of CRUD:
Hot Cocoa
Beverage
Mix Cocoa packet with water.
Heat. Stir.
Create
Modify
General Tasks
Discussion: The following procedure represents the tasks
we will follow to complete the “search.php” application.
0. Convert from HTML to PHP.
1. Perform the following tasks:
a.Initialize variables (Step 0)
b.Connect to database (Step 1)
c.Use a database (Step 2)
d.Close the database connection (Steps 6).
General Tasks
Discussion: The following procedure represents the tasks we
will follow to complete the “search.php” application.
2. Perform the following tasks :
a.Build the SQL “SELECT” statement (Step 3).
b.Execute the SQL statement (Step 4).
3. Build a SQL debug statement.
4. Build a HTML table with database data:
b.Obtain results from “SELECT” statement (Step 5)
c.Display data in dynamic HTML table.
General Tasks (cont. 2)
5. Remove the static HTML table.
6. Make form changes:
a. Make form self-referential (action
flexibility).
b. Make text field “sticky” (remember
previous state).
7. Populate drop-down list with DB values.
General Tasks (cont. 3)
8. Add search capabilities for title.
9. Add search capabilities for category.
10. Add search capabilities for content.
11. Make checkboxes “sticky”.
12. Separate CSS into a separate file.
13. Separate JavaScript into separate file.
General Tasks (cont. 4)
Discussion: The items below are the tasks and the
procedure we will follow to complete the
“delete.php” application.
14. Perform the following tasks:
a. Connect and use the database (Steps 1 & 2).
b. Build the SQL “DELETE” statement (Step 3).
c. Execute the SQL statement (Step 4).
d. Obtain results from “DELETE” statement
(Step 5).
to be continued ...
http://webcert.kirkwood.edu/~fmccl
urg/courses/php/slides/recipe02.ppt