Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

Can someone please tell me which syntax to use to build the "directory" array from a mysql recordset? Thank you!

$directory = array();

foreach ($resultSetFromDB as $row){

    foreach ($row as $field => $value){

        $directory[$field][] = $value;

    }
}

I can print $field and $value, no problem

share|improve this question
    
can we see the recordset? –  EvilEpidemic May 29 at 13:10
    
add more description in your question. it is not clear what do you want –  Awlad Liton May 29 at 13:10
add comment

1 Answer

up vote 1 down vote accepted

Try this:

$directory = array();

foreach ($resultSetFromDB as $i => $row) {

    foreach ($row as $field => $value) {

        $directory[$i][$field] = $value;

    }
}
share|improve this answer
    
that did it. bless you! –  user3687643 May 29 at 13:15
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.