1 Insert, Update and Delete Queries. 2 Return to you Address Book database. Insert a record

  • View
    215

  • Download
    1

Embed Size (px)

Text of 1 Insert, Update and Delete Queries. 2 Return to you Address Book database. Insert a record

  • Slide 1
  • 1 Insert, Update and Delete Queries
  • Slide 2
  • 2 Return to you Address Book database. Insert a record.
  • Slide 3
  • 3 Recall that this action provides the SQL, better yet it will provided the PHP that writes the SQL.
  • Slide 4
  • 4 Copy the code and put it somewhere for safe keeping
  • Slide 5
  • 5 Saved PHP-SQL code in Notepad
  • Slide 6
  • 6 Mark a record and click the pencil icon to update that record.
  • Slide 7
  • 7 Change some fields and click Go.
  • Slide 8
  • 8 Rats. I didnt see any SQL Update query to copy.
  • Slide 9
  • 9 Mark a record and click on the Delete button
  • Slide 10
  • 10 Copy the SQL for the DELETE, then decide whether you want to delete this record or not.
  • Slide 11
  • 11 Saved DELETE query
  • Slide 12
  • 12 Start two PHP files, place a form and a table with one row and two columns on the first page.
  • Slide 13
  • 13 Add a list/menu and a submit button in column 1 and a radio group in column 2.
  • Slide 14
  • 14 Corresponding code.
  • Slide 15
  • 15 Add PHP code for putting names into list/menu.
  • Slide 16
  • 16 Result so far.
  • Slide 17
  • 17 Add a second form and second table with 1 row (to start) and 3 columns
  • Slide 18
  • 18 Corresponding code
  • Slide 19
  • 19 After the row ( ) but before end of table ( ), start PHP code block. Make array of database filed names.
  • Slide 20
  • 20 Write a foreach loop that iterates over the FieldArray making a table row corresponding to each
  • Slide 21
  • 21 Result so far.
  • Slide 22
  • 22 Add SQL query before foreach loop, edit middle column code.
  • Slide 23
  • 23 Result so far
  • Slide 24
  • 24 Add non-breaking space ( ) to middle column
  • Slide 25
  • 25 After non-breaking space was added to middle column
  • Slide 26
  • 26 Add if so no Old data is showing for Insert choice
  • Slide 27
  • 27 Problem The radio buttons do not hold onto the information about what choice was clicked before.
  • Slide 28
  • 28 The top forms action is the same page, so it can refer to its own $_POST array. I add some php script in the radio button tags to check the appropriate radio button.
  • Slide 29
  • 29 Add if structure that remembers which item from the list was selected The extra word selected in the option tag will indicate which of the option should be showing.
  • Slide 30
  • 30 Added some code so that textboxes are read only and gray when Delete is the chosen action
  • Slide 31
  • 31 Remembers selected person, remembers selected action, grays out textboxes when delete is selected action.
  • Slide 32
  • 32 Add submit button to bottom form.
  • Slide 33
  • 33 Show old data in textbox (as starting point) when Update is selected action.
  • Slide 34
  • 34 Result showing old data in textbox (as starting point) when Update is selected.
  • Slide 35
  • 35 Insert Hidden Fields (to hold info from top form on bottom form so it can be passed to handler of bottom form)
  • Slide 36
  • 36 Result of hidden fields added
  • Slide 37
  • 37 PHP code to get values from top form onto bottom form
  • Slide 38
  • 38 Handler code to determine action requested on calling page
  • Slide 39
  • 39