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 trialAmit Kumar
1,063 PointsHow $_GET variable is automatically set on clicking some link like books ,movies,music
How $_GET variable is automatically set on clicking some link like books ,movies,music
if we write in url like http://somthing?id=books
then i can understand but on clicking how.
2 Answers
molo
8,927 PointsThe get_item_html function shows this. It outputs each item into it's own list using <li></li> which includes the image, title, and also a href link.
function get_item_html($item) {
$output = "<li><a href='details.php?id="
. $item["media_id"] . "'><img src='"
. $item["img"] . "' alt='"
. $item["title"] . "' />"
. "<p>View Details</p>"
. "</a></li>";
return $output;
}
'details.php?id=" . $item["media_id"] . The string after the ? and before the = is the $_GET. $_GET['id']
Benjamin Larson
34,055 PointsI'm a little confused by the question, but I think you are asking how a link would be programmed to generate a string in the URL to retrieve the appropriate data? If that's the case, then I think if the next few videos in that series should answer your question as you will build up links for the pagination.