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

Displaying the results of the query - PHP Tutorial

From the course: PHP for Web Designers

Start my 1-month free trial

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…

Contents