From the course: PHP for Web Designers
Unlock the full course today
Join today to access over 22,500 courses taught by industry experts or purchase this course individually.
Linking to a details page - PHP Tutorial
From the course: PHP for Web Designers
Linking to a details page
When you click one of the images in the Mixed Arrangements page of the Hansel & Petal website, it takes you to a details page which contains some hard coded dummy text. It doesn't matter which image you click. You always come back to the same page. So let's adapt this page, so that it loads the details of the correct product. And for it to do so, the links to this details page need to identify which image has been clicked. The main content in the Mixed Arrangements page is being drawn from a database. So if we have a quick look at the database, we can see what we can use to identify each image. And each row in the database table contains an ID. One, two, three, four, five, etcetera. So, we can use that in a query string of our URL. So, let's go to our Editing program. And the link to Details PHP is on line 64. What we need to do is to add query string at the end of that, so question mark, ID equals, and then we need to have a PHP block to show us the ID, the value. And we're going…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
(Locked)
Loading data into MySQL5m 37s
-
(Locked)
Connecting to the database7m 47s
-
Querying the database6m 15s
-
(Locked)
Displaying the results of the query3m 50s
-
(Locked)
Using modulo division to establish a repeating series4m 20s
-
(Locked)
Repeating output at specific intervals in a loop4m 56s
-
(Locked)
Linking to a details page2m 40s
-
(Locked)
Embedding a variable in a query securely6m 5s
-
(Locked)
Handling database errors gracefully--and securely8m 40s
-
(Locked)
-
-