450 likes | 759 Views
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.
E N D
Recall that this action provides the SQL, better yet it will provided the PHP that writes the SQL.
Mark a record and click the pencil icon to update that record.
Copy the SQL for the DELETE, then decide whether you want to delete this record or not.
Start two PHP files, place a form and a table with one row and two columns on the first page.
Add a list/menu and a submit button in column 1 and a radio group in column 2.
Add a second form and second table with 1 row (to start) and 3 columns
After the row (</tr>) but before end of table (</table>), start PHP code block. Make array of database filed names.
Write a foreach loop that iterates over the FieldArray making a table row corresponding to each
Problem • The radio buttons do not hold onto the information about what choice was clicked before.
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.
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.
Added some code so that textboxes are read only and gray when Delete is the chosen action
Remembers selected person, remembers selected action, grays out textboxes when delete is selected action.
Show old data in textbox (as starting point) when Update is selected action.
Result showing old data in textbox (as starting point) when Update is selected.
Insert Hidden Fields (to hold info from top form on bottom form so it can be passed to handler of bottom form)