AFAIK, you are going to have to use a while loop to get the data out. What you want to do is make your own array while iterating through the data loop.
Since I use phplib to do my extraction from a database, I don't remember how to do it with native php functions-- but I think you'll pick up the idea:
$db->query("select id,first,last from some_table");
while($db->next_record()) {
// I'll do this the long way to be clear...
$id = $db->f('id');
$first = $db->f('first');
$last = $db->f('last');
// make your data structure
$name[$id] = array('first'=>$first,
'last' =>$last
);
}
// then you can access it like this:
printf("The first guy is %s %s. Another guy you might meet is %s %s.",
$name[1]['first'],
$name[1]['last'],
$name[3]['first'],
$name[3]['last']
);