SELECT

SELECT

Written

Query, as in, to ask a question. Working with a database, this concept will be put to very good use.

On the INSERT tutorial page, you've already seen a QUERY in action. The query asked the database to insert the new information into the specified database table.

The SELECT property can be used in a mysql_query command to choose specific information in the database table.

The variable $sql is being used to find the information in the address_book table. The * is a symbol meaning "all". It will look at all of the records FROM the specified table.

To look at each row in the specified area, the next step is to use a loop and the mysql_fetch_row command with the SELECT information.

WHILE the statement is TRUE, the loop will continue.

The mysql_fetch_row command will take the supplied information and read the data from the next available row of the database.

The ECHO command being used to display the data during each row loop is a simple one for example purposes. The columns of a database are numbered starting at zero. The variable $row is assigned the current row contents during each loop.

Table of Contents

Previous
INSERT