insert, update and delete queries
DESCRIPTION
Insert, Update and Delete Queries. Return to you Address Book database. Insert a record. Recall that this action provides the SQL, better yet it will provided the PHP that writes the SQL. Copy the code and put it somewhere for safe keeping. Saved PHP-SQL code in Notepad. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/1.jpg)
1
Insert, Update and Delete Queries
![Page 2: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/2.jpg)
2
Return to you Address Book database. Insert a record.
![Page 3: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/3.jpg)
3
Recall that this action provides the SQL, better yet it will provided the PHP that writes the SQL.
![Page 4: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/4.jpg)
4
Copy the code and put it somewhere for safe keeping
![Page 5: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/5.jpg)
5
Saved PHP-SQL code in Notepad
![Page 6: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/6.jpg)
6
Mark a record and click the pencil icon to update that record.
![Page 7: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/7.jpg)
7
Change some fields and click Go.
![Page 8: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/8.jpg)
8
Rats. I didn’t see any SQL Update query to copy.
![Page 9: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/9.jpg)
9
Mark a record and click on the Delete button
![Page 10: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/10.jpg)
10
Copy the SQL for the DELETE, then decide whether you want to delete this record or not.
![Page 11: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/11.jpg)
11
Saved DELETE query
![Page 12: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/12.jpg)
12
Start two PHP files, place a form and a table with one row
and two columns on the first page.
![Page 13: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/13.jpg)
13
Add a list/menu and a submit button in column 1 and a radio group in column 2.
![Page 14: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/14.jpg)
14
Corresponding code.
![Page 15: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/15.jpg)
15
Add PHP code for putting names into list/menu.
![Page 16: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/16.jpg)
16
Result so far.
![Page 17: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/17.jpg)
17
Add a second form and second table with 1 row (to start) and 3 columns
![Page 18: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/18.jpg)
18
Corresponding code
![Page 19: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/19.jpg)
19
After the row (</tr>) but before end of table (</table>), start
PHP code block. Make array of database filed names.
![Page 20: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/20.jpg)
20
Write a foreach loop that iterates over the FieldArray making a table row corresponding to each
![Page 21: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/21.jpg)
21
Result so far.
![Page 22: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/22.jpg)
22
Add SQL query before foreach loop, edit middle column code.
![Page 23: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/23.jpg)
23
Result so far
![Page 24: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/24.jpg)
24
Add non-breaking space ( ) to middle
column
![Page 25: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/25.jpg)
25
After non-breaking space was added to middle column
![Page 26: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/26.jpg)
26
Add if so no Old data is showing for “Insert” choice
![Page 27: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/27.jpg)
27
Problem
• The radio buttons do not hold onto the information about what choice was clicked before.
![Page 28: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/28.jpg)
28
The top form’s 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.
![Page 29: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/29.jpg)
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.
![Page 30: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/30.jpg)
30
Added some code so that textboxes are read only and gray when Delete is the chosen action
![Page 31: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/31.jpg)
31
Remembers selected person, remembers selected action, grays out textboxes when delete is selected action.
![Page 32: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/32.jpg)
32
Add submit button to bottom form.
![Page 33: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/33.jpg)
33
Show old data in textbox (as starting point) when Update is selected action.
![Page 34: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/34.jpg)
34
Result showing old data in textbox (as starting point) when Update is selected.
![Page 35: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/35.jpg)
35
Insert Hidden Fields (to hold info from top form on bottom form so it can be passed to handler of bottom form)
![Page 36: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/36.jpg)
36
Result of hidden fields added
![Page 37: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/37.jpg)
37
PHP code to get values from top form onto bottom form
![Page 38: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/38.jpg)
38
Handler code to determine action requested on calling page
![Page 39: Insert, Update and Delete Queries](https://reader035.vdocuments.mx/reader035/viewer/2022062221/56813c69550346895da5fad7/html5/thumbnails/39.jpg)
39