http:www'cse'msu'educse103 - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

http:www'cse'msu'educse103

Description:

http:www'cse'msu'educse103 – PowerPoint PPT presentation

Number of Views:47
Avg rating:3.0/5.0
Slides: 16
Provided by: vaughna3
Learn more at: https://www.msu.edu
Category:
Tags: class | cse | educse103 | http | msu | www

less

Transcript and Presenter's Notes

Title: http:www'cse'msu'educse103


1
Back-up PHP Files
  • If you have not yet passed the 3.0 BT, make
    back-up copies of ALL of your PHP files (BEFORE
    you start todays class work) to use when you
    take the 3.0 BT.
  • What we cover today may complicate taking the BT
    if you try to use it then

2
Review of Day 23
  • Create a form page, addmovie_form.php that has
    text boxes for the title and year
  • Create a handler page addmovie_handler.php
  • Write SQL query to add title and year to
    tbl_Movies
  • INSERT INTO tbl_Movies (MovieTitle, Year) VALUES
    ('valueForMovieTitle', valueForYear)
  • Use form information via _POSTName, where
    Name is the name of the form ltinputgt element
  • Use insert_autonumbered_row() to submit the query
  • Save new id returned by function in new PHP
    variable

3
Review of Day 23 continued
  • Add a form element for entry of Genre data to the
    addmovie_form.php page. Make this form element a
    drop-down box.
  • Use only Genres listed in tbl_Genres
  • Use print and the CSE 103 support function
    dropbox_from_query() to make the dropbox on the
    form. (Dont use a normal form element!)
  • Requires a query that selects two fields one a
    key value and one something to be displayed

4
Review of Day 23, part 3
  • Change the addmovie_handler.php page to also add
    the genre information to the database.
  • Assign the autonumber ID (created when title and
    year are added to tbl_Movies) to a variable.
  • Use that variable in constructing a query to add
    the movieID and the submitted genre info (and
    rank 1) to tbl_MovieGenres
  • The _POST'name' for this matches the 2nd
    argument to dropbox_from_query() on your form
    page
  • Use the CSE 103 support function
    run_action_query() to run this query.

5
Adding Movies Considerations
  • Q1 How can we determine if the add is
    successful?
  • Q2 How can we determine if a movie is in the
    database already?
  • Q3 What should we do if a movie is already in
    the database?

6
A1 The IF statement
  • The IF statement lets us perform one or another
    set of actions based on the value of a test.
  • The test must have a value of either true or
    false.
  • It uses relational operators lt, gt,ltgt,, etc.
  • If true, the first set of statements after the IF
    are executed.
  • If false, the statements after an else (following
    the if) are performed instead.

7
Example IF test
  • if ( MovieID 0)
  • print "No movie added"
  • else
  • print "Movie added with ID "
  • print MovieID
  • Autonumber IDs are never 0, so if 0 was returned,
    we know we didn't get a "real" ID

8
First Conditional Exercise
  • Modify your addmovie_handler.php page to test
    whether or not the action query on tbl_Movies is
    successful
  • What does it mean that a movie was added?
  • Display appropriate messages to the user and take
    other appropriate actions in each case.
  • What should you do if adding the record is
    successful? if it is not successful?

9
A2 A3 Check for a pre-existing entry and action
  • Write an SQL query to test whether or not a
    MovieTitle and Year combination is already in the
    database.
  • What can we look for that we can easily test?
  • Use the returned value in an IF test
  • How should we test? What does our test mean if
    true?
  • If the movie IS NOT in the database, then add it
    as a new record and continue as before.
  • If the movie IS in the database, display a
    message to that effect plus its MovieID.
  • STOP and do not attempt to insert the data

10
Dynamic Web Page Design
  • How should I put dynamic pages together to form a
    site?
  • Organization chart is very helpful, as used in
    CSE 101
  • What information is needed to construct each
    page?
  • What interface do I want to present to the user?

11
End-of-Term SIRS
  • Link on the Student Site Map
  • Three forms Course, Lead , and Asst
  • Comments will be considered for future course
    development of CSE 101
  • Available until Thursday, April 28th at 4pm, when
    UBTs are due
  • Necessary to access your BT Feedback

12
UBT Databases
  • Each student in CSE 103 currently has a MySQL
    database
  • Database name is students msuNetID
  • Database is currently empty unless you already
    submitted an Access database for us to convert

13
To create UBT Databases
  • You submit (via e-mail) an Access db file to
    cse103_at_cse.msu.edu with desired table structures
    (fieldnames and datatypes)
  • Also look for other properties like Required?
  • Don't bother with lookups we can't convert those
  • DO bother with relationships (helps us
    understand)
  • We will create the tables in your db from your
    Access sample.
  • You create the web forms and action pages to
    enter data into those tables and to manipulate
    the data as needed for your UBT project.

14
A good UBT should
  • Demonstrate good database design
  • Appropriate tables, fields, datatypes, keys, and
    relationships, as well as integrity and minimal
    redundancy (everything related to the 2.0 BT)
  • Demonstrate mastery of various queries
  • Both Select and Action, use of functions,
    calculated fields, aggregate functions, etc.
  • Demonstrate ability to learn new concepts
  • Use new functions, query types, etc. that we
    didnt cover in-class or on any BT

15
Remainder of Semester
  • Day 26 (Thurs/Mon) - In-Class BT Opportunity
  • Day 27 (next Tue/Wed) - In-Class Helproom
  • Day 28 (next Thurs/week from Mon) - In-Class BT
    Opportunity
  • Thursday, April 28th - UBTs due at 4 pm
  • On Days 26 and 28, your Lead will be in the CSE
    103 office during class hours if you have already
    passed 3.0 and need UBT help
  • Feel free to e-mail with UBT questions when
    working
Write a Comment
User Comments (0)
About PowerShow.com