Hello,

What I intend to do is put the database query results in a
multidimentional array like this.

$sponsor_id['sponsor1'] = ('project1 title', 'project2 title', 'project3
title');
$sponsor_id['sponsor2'] = ('project1 title','project7 title');
....

Here is the code snippet for doing that:

==
while( ($rec = odbtp_fetch_array($qry)) ) {

           if (empty($sponsor_id[$rec[1]])) {
                  $sponsor_id[$rec[1]] = array();
           } else {
                       array_push($sponsor_id[$rec[1]], $rec[0]);
              }
         }
==

Now, when the following code is used to print the array $sponsor_id, it
only prints out the keys of the array which are:

sponsor1
sponsor2

Those project titles are not printed out.

==
foreach ($sponsor_id as $sponsor => $arr)
            echo "$sponsor:";
            foreach ($arr[$sponsor] as $project) {
                echo "$project<br>";
            }
==

My expected output should be like:

sponsor1:
  project1 title
  project2 title
  project3 title

sponsor2
  project1 title
  project7 title

What is wrong?  I'd appreciate any help.

Thanks,

Bing

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to