Well, you could have a master class called users, which returns an array of objects from the "user" class - you could then access each individual user object, or fetch all.
for example
PHP Code:
<?
class Users{
var $userArray;
function __construct(){
$q = mysql_query("SELECT * FROM users_table");
while($row = mysql_fetch_array($q)){
$this->userArray[$username] = new User($username);
}
}
function get_all_users(){
return $this->userArray;
}
function get_user($username){
return $this->userArray[$username];
}
}
class User{
var $userid, $username;
function __construct($username){
$q = mysql_query("SELECT * FROM `users_table` WHERE `username`='".$username."'");
$this->userid = mysql_result($q, 0, 'id');
$this->username = mysql_result($q, 0, 'username');
}
function getUserId(){
return $this->userid;
}
}
then you could use something like:
PHP Code:
<?
$users = new Users;
$userarray = get_all_users();
foreach($userarray as $user){
echo $user->getUserId();
}
Hope that helps.
Bookmarks