Topic: Need a list/vector with all the usernames

I need a list or vector with all the registred users usernames in the forum. How do I do?

2 (edited by Mastodon 2006-04-13 21:14)

Re: Need a list/vector with all the usernames

define('PUN_ROOT', './'); //change this to your forum's directory
require PUN_ROOT.'include/common.php';

$result = $db->query('SELECT username FROM '.$db->prefix.'users') or error('Unable to fetch user usernames', __FILE__, __LINE__, $db->error());
$usernames = $db->fetch_assoc($result);

That'll put all your users usernames in a $usernames array unless I've borked it somehow.

Re: Need a list/vector with all the usernames

That gets the first username from the resultset and puts it into $usernames wink
You'd want to do a while loop to get it into an array

Re: Need a list/vector with all the usernames

Gahaha, too right. I need caffeine.

define('PUN_ROOT', './'); //change this to your forum's directory
require PUN_ROOT.'include/common.php';

$result = $db->query('SELECT username FROM '.$db->prefix.'users') or error('Unable to fetch user usernames', __FILE__, __LINE__, $db->error());
while ($row = $db->fetch_assoc($result)) {
 $usernames[] = $row['username'];
}