$sql = mysql_query("select id, name, code from users");
$userinfo = array();
while ($row_user = mysql_fetch_assoc($sql))
$userinfo[] = $row_user;
Ini akan memberi Anda $userinfo
sebagai array dengan struktur berikut:
[
[id => 1, name => 'gorge', code => '2123'],
[id => 2, name => 'flix', code => 'ksd02'],
[id => 3, name => 'jasmen', code => 'skaod2']
]
Jika Anda ingin menampilkan data:
foreach ($userinfo as $user) {
echo "Id: {$user[id]}<br />"
. "Name: {$user[name]}<br />"
. "Code: {$user[code]}<br /><br />";
}