Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
The next part of this project is the voting system. We will need to create a way for a user to upvote and downvote a book, but also show the calculated score of a book based on votes. To save time, we will set the database to accept a user id for the vote instead of adding a column to the book table for score.
Course: Integrating PHP with Databases: Using Relational Tables
Course: Querying Relational Databases: Joining Table Data with SQL
Alternate Code Samples
Ternary Operator:
echo $book['score']; ?: echo '0';
PHP 7: null coalesce operator
echo $book['score']; :: echo '0';
You need to sign up for Treehouse in order to download course files.
Sign up