tags:

views:

191

answers:

1

I am looking to create an array of data to be pass to another function that is populated from a database query and am not sure how to do this.

$dataArray[0][1];

$qry = mysql_query("SELECT Id, name FROM users");

while($res = mysql_fetch_array($qry)) {
    $dataArray[$res['Id']][$res['name']]
}

Thanks in advance.

+3  A: 

This would look better

$dataArray = array();

$qry = mysql_query("SELECT Id, name FROM users");

while($res = mysql_fetch_array($qry)) {
    $dataArray[$res['Id']] = $res['name'];
}

you can take a look at the PHP manual how to declare and manipulate arrays.

RageZ
Thanks this is great.
aHunter