As before, I can retrieve this information via an SQL query,
mysql> SELECT uid, username, age, sex, tel FROM users;
+-----+----------+-----+-----+-----------+| uid | username | age | sex | tel |+-----+----------+-----+-----+-----------+| 1 | joe | 19 | M | 123 4567 || 2 | sarah | 35 | F | 543 18238 || 3 | john | 22 | M | 853 2377 || 4 | william | 31 | M | 123 2372 |+-----+----------+-----+-----+-----------+4 rows in set (0.00 sec)
or have patUser do it for me via its getUsers() function:
<?php
// include classesinclude("../include/patDbc.php");include("../include/patUser.php");// initialize database layer$db = new patMySqlDbc("localhost", "db211", "us111", "secret");// initialize patUser$u = new patUser(true);// connect patUser to database$u->setAuthDbc($db);// set table$u->setAuthTable("users");// get user list$list = $u->getUsers(array("uid", "username", "age", "sex", "tel"));// print as tableecho "<h2>Users</h2>";echo "<table border=1>";echo "<tr>";echo "<td><b>UID</b></td>";echo "<td><b>Username</b></td>";echo "<td><b>Age</b></td>";echo "<td><b>Sex</b></td>";echo "<td><b>Tel</b></td>";echo "</tr>";// iterate over listforeach ($list as $l){ echo "<tr>"; echo "<td>" . $l['uid'] . "</td>"; echo "<td>" . $l['username'] . "</td>"; echo "<td>" . $l['age'] . "</td>"; echo "<td>" . $l['sex'] . "</td>"; echo "<td>" . $l['tel'] . "</td>"; echo "</tr>";}echo "</table>";?>
In this case, I've told getUsers() to retrieve a few extra fields from the database - specifically, the "age", "sex" and "tel" fields. You'll remember these are not standard patUser fields, but have been added by me for illustrative purposes.