In response to your comment:
You're retrieving data from a mySQL database, so you can just fetch the data as an associative array:
PDO:
//just as an example
$stmt = $pdo->prepare('SELECT foo, bar from foobar.foobaz WHERE xyz = :xyz');
$stmt->execute(array(':xyz' => $someValue));
$results = array();
while($row = $stmt->fetch(PDO::FETCH_ASSOC))
{
array_push($results, $row);
}
That should do it. Of course, there is mysql_fetch_assoc
, but since the mysql_*
extension is deprecated, I'm not going to bother with that, just switch to PDO, if you haven't already.
If you're not comfortable with PDO for some reason, look into mysqli_*
, in which case the loop looks like this:
while($row = $stmt->fetch_assoc())
{//using OO api
array_push($results, $row);
}
//or
while($row = mysqli_fetch_assoc($result))
{//using OO api
array_push($results, $row);
}
full examples [on the doc pages](http://www.php.net/mysqli_fetch_assoc