In this solution to the challenge assignment, Kevin demonstrates how to build a PHP page which will connect to the database, query for all records in the pages table, and then loop through the result set to output a list of pages.
- [Instructor] Hopefully you were able to complete…the challenge assignment on your own.…If not, in this movie, I'm going to show you the solution…that I came up with; and you can follow along with me.…The first thing we know we need to do is we need…to make a connection to the database.…We had already created much of this functionality already…in the chapter, and we're just going to reuse it;…but it's good to review it to make sure…that you understand it.…The key part is here, what we're calling mysqli_connect,…and we're passing in our credentials.…Those are constants that we're getting…out of the DB credentials file, and then I'm getting back…from that connection a connection.…
So if the connection succeeded,…I'll have a connection handle that I can use to work with;…and then I'll return that down here in this line.…I've also still got this error checking code in here,…so it's going to confirm that there wasn't an error.…So if, for some reason, something went wrong…with the connection, it'll just handle the error…
- Organizing project files
- Including and requiring files
- Working with URL parameters
- Encoding dynamic content
- Modifying headers and page redirection
- Creating forms and processing form data
- MySQL basics
- Using PHP to access database tables
- Creating, reading, updating, and deleting database records with PHP
- Validating data
- Preventing SQL injection
Skill Level Beginner
1. Start a Database-Driven Project
2. Build Web Pages with PHP
3. Headers and Redirects
4. Build Forms with PHP
5. MySQL Basics
6. Use PHP to Access MySQL
7. CRUD with PHP
8. Validate Data with PHP
9. Prevent SQL Injection
Next steps1m 8s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.