Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Integrating PHP with Databases Limiting Records in SQL Calculations and Links

How 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

Hi 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&param2=2&param3=3

More info:

https://www.encodedna.com/2012/11/querystring-multiple-parameters.htm

I hope that helps.

Stay safe and happy coding!