i'm going thru the o'reilly php & mysql book (2nd ed). all's well til example on page 186.
i'm not sure where the numbers in the array index come from.
Code:
// Fetch and display the results
while ($result_row = mysql_fetch_row(($result))){
echo 'Title: '.$result_row[1] . '<br />';
echo 'Author: '.$result_row[4] . '<br /> ';
echo 'Pages: '.$result_row[2] . '<br /><br />';
}
it runs ok but i think i'm missing where the [1],[4],[2] come from.
i logged into the mysql command line & ran the same query from the book:
Code:
SELECT * FROM books NATURAL JOIN authors;
and it showed:
Code:
mysql> SELECT * FROM books NATURAL JOIN authors;
+----------+-------------------------+-------+-----------+------------
----+
| title_id | title | pages | author_id | author
|
+----------+-------------------------+-------+-----------+------------
----+
| 1 | Linux in a Nutshell | 112 | 1 | Ellen
Siever |
| 1 | Linux in a Nutshell | 112 | 2 | Aaron Weber
|
| 2 | Classic Shell Scripting | 256 | 3 | Arnold
Robbins |
| 2 | Classic Shell Scripting | 256 | 4 | Nelson
Beebe |
+----------+-------------------------+-------+-----------+------------
----+
4 rows in set (0.00 sec)
Bookmarks