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 trialMatt Nickolls
9,895 PointsHow does the ampersand (&) allow us to pass the page number?
If $limit_results is not empty Alena notes an "&" is used to get the page number. Could this be explained? She makes the comment in relation to:
if (!empty($section)) { $limit_results = "cat=" . $section . "&; }
1 Answer
Peter Vann
36,427 PointsHi Matt!
You have to imagine the queryString she is constructing via concatenation.
The end result would be something like:
Location:catalog.php?cat=sectionName&pg=totalPagesInt
where sectionName would be an actual section name and totalPagesInt would be an actual integer, such as 4.
The & is the convention in query strings that allows you to pass in multiple variables/parameters.
Consider this valid queryString:
localHost/myExamplePage.php?param1=1¶m2=2¶m3=3
More info:
https://www.encodedna.com/2012/11/querystring-multiple-parameters.htm
I hope that helps.
Stay safe and happy coding!