From the course: PHP for Web Designers
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Displaying the results of the query - PHP Tutorial
From the course: PHP for Web Designers
Displaying the results of the query
Now that we've confirmed that our query isn't generating any errors, we can go ahead with displaying the results of our query. So let's go down to the section where we want to display the results. There it is. We need to put a loop, so we put one row of results each time that the loop runs. So the loop begins above the div for section. A PHP block there. And the type of loop that I'm going to use this time is called a while loop, and the condition that I'm going to have in the while loop will be, getting one row of results at a time. And I'm going to store that in a variable called row. And assign to that result. Then the arrow operator, and its fetch_assoc, so it's fetching an associative array, which will be called row. And that would be one row of results at a time. So we need an opening curly brace for our while loop. Then we need to find the closing div tag. There it is. And that's where the closing curly brace of that loop will go. And to remind ourselves of what it is, add a…
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)
-
-