Quakenet/#php Tutorial

Note: If you opened this page from an external URL pay attention that all chapters are linked together. Be sure you also read all prior chapters of this tutorial, otherwise you will miss relevant content explained before.

MySQL / Read data from a table

  1. SELECT on tables

1. SELECT on tables

As we can read single values we try to read data from a table. We extend the SELECT query by the FROM ... keyword. The ... part is the table we want to read. If we have select a table this way we can use the column names in the SELECT part. So the syntax is SELECT columns FROM table. As an example we reads the columns id, author and title from our news table.


We get the following result set.

Result set of the SELECT query
author id title
Me 2 My first news

We see we got a result set with 3 columns and 2 rows. This is okay as the table got 2 rows and in the SELECT part we selected 3 columns. We also see the first row got empty values but thats also okay as the row itself just got only empty values. The order of the columns can be changed (we read id after author), but it doesn't matter as we read them in php by their name rather by their position.

Questions about the chapter

No questions

Back to Next to
Copyright © to the OPs of #php/QuakeNet Valid XHTML 1.0 Strict Valid CSS!