Database Array

Arrays are a crucial element of php. There are a number of array functions, look on php.net to see them.  http://us2.php.net/manual/en/book.array.php

Data from databases is usually returned as an array, so given a table like this:

mysql> describe quotes;
+--------+-----------------+------+-----+---------+----------------+
| Field  | Type            | Null | Key | Default | Extra          |
+--------+-----------------+------+-----+---------+----------------+
| id     | int(7) unsigned | NO   | PRI | NULL    | auto_increment |
| source | int(2) unsigned | YES  |     | NULL    |                |
| quote  | text            | YES  |     | NULL    |                |
| kw     | varchar(50)     | YES  |     | NULL    |                |
+--------+-----------------+------+-----+---------+----------------+

and given the query, “select * from quotes limit 1” the mysql_fetch_assoc() function  might return something like:

Array
(
    [id] => 7
    [source] => 1
    [quote] => "Nothing more will be taken from you.' - Master Po
 'But I have lost nothing.' - Young Caine
 'But your innocence How shall that be returned?'" - Master Po
    [kw] =>
)

That output is from the print_r() function, so if “$row” is the name of hte array, then you’d call print_r as print_r($row)

You can create an array a number of ways:

$arr = array(‘apple’, ‘orange’, ‘bananna’);

is pretty much the same as:

$arr = array();

$arr[] = ‘apple’;

$arr[] = ‘orange’;

$arr[] = ‘banana’;