Order Data From Database in PHP
Total Size: 1.42 KB
Created: 6 months ago
Edited: 6 months ago
The following example selects the id, firstname and lastname columns from the MyGuests table and displays it on the page.
First, we set up an SQL query that selects the id, firstname and lastname columns from the MyGuests table. The next line of code runs the query and puts the resulting data into a variable called $result.
function num_rows() checks if there are more than zero rows returned.
If there are more than zero rows returned, the function
fetch_assoc() puts all the results into an associative array that we can loop through. The
while() loop loops through the result set and outputs the data from the id, firstname and lastname columns.
Are you sure you want to delete?