⇧
vadnica-logo
My Services About the Project Telegram O meni O meni

Reading and Displaying Data from a Database

The SELECT statement is used to select data from one or more tables, or we can use the * (asterisk) character to select all columns from a table. First, we set up an SQL query that selects the id, fruit, and vegetable columns from the table. The next line of code runs the query and transfers the obtained data into a variable named $rezultat. Then the num_rows() function checks whether more than zero rows are returned, and if so, the fetch_assoc() function puts all results into an associative array that we can work with. A while() loop iterates through the result set and prints the data from the id, fruit, and vegetable columns.

EXAMPLE
RESULT
The result will be displayed here...