Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialSeth Warner
5,348 PointsCan someone re-explain why its there and how exactly the if statement is working?
I think I got all of it up to why he put the if statement like that.
2 Answers
Micah Courey
20,168 PointsThe if statement is checking whether the film has a var of 'id' and also that its not empty. If the film id is not empty we want to set the $film_id = to the 'id' and then we can concatenate the GET var onto the end of the database query.
Mai Lon Ross
5,891 PointsIn the index page, the foreach loop gets the items that make up the ordered list. The ahref puts a link in each title, that will also pass along the id of the film with the GET variable. Then the if statement in films.php checks to see if that GET variable (the film id) was passed along from the index page, and if it was it puts it in the variable $film_id.
Seth Warner
5,348 PointsSeth Warner
5,348 Pointsso the ahref is saying for each films as film from the films.php, specifically from the [“film_id”] return it in a ordered list? Then after that the if statement dose what exactly, one more time, sorry I'm trying to understand where the $_get is coming from, idk what that is