I m trying to create a function to return all of the users in a database as an array. When I print_r the users, I m getting a multi-dimensional array returned:
注
Array ( [0] => Array ( [0] => Albers [1] => Abbings [2] => Blaine [3]
Code:
<?php
session_start();
function getActiveUsers() {
$con = mysql_connect("-","-","-");
if (!$con)
{
die( Could not connect: . mysql_error());
}
else {
// connected to database successfully
}
mysql_select_db("casemanagers", $con);
$result = mysql_query( select * from users );
$arr = array();
while($row= mysql_fetch_assoc($result)){
$arr[] = $row[ Name ];
}
return array ($arr);
}
$row = array();
$row = getActiveUsers();
print_r($row);
?>
谁能告诉我,为什么发生这种情况,或者我可以采取哪些步骤来解决这个问题? 感谢。