Edit Procedure2:44 with Alena Holligan
We'll finalize our book modifications by creating the editBook procedure.
We need to set up the edit procedure. 0:01 Let's copy our addBook. 0:04 And create a new file named editBook. 0:11 First we need to add the bookId. 0:16 Then we change the addBook function to updateBook. 0:30 And we pass the bookId as well. 0:40 And finally we change add.php to edit. 0:43 And we need to pass the bookId. 0:49 Next we need to create the updateBook function in the functions file. 0:57 Let's close out some of these files. 1:06 And let's start by duplicating the addBook. 1:12 We'll change this to updateBook, and accept the bookId. 1:24 Now we need to change the SQL statement. 1:30 UPDATE books. 1:36 SET name=:name, description=:description. 1:44 WHERE. 1:54 Id = bookId. 2:03 We'll remove the ownerId from here. 2:08 And we'll change ownerId to bookId. 2:12 Let's check this out in the browser. 2:27 Great. 2:43
You need to sign up for Treehouse in order to download course files.Sign up