Re: SELECT into array of arrays

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> How should I proceed? Thanks in advance for any suggestions.

Since you are looping through the result already, why not do it this way ..

$combinedArray = array();
for ($i=0;$i<count($myArray);$i++) {

$sql = "SELECT study,symbol FROM test WHERE study IN ('$myArray[$i]')";
$result = mysql_query($sql);

if(mysql_num_rows($result) > 0) {
   while ($myrow = mysql_fetch_array($result)) {
       if (in_array($myrow['study'], $myArray))
$combinedArray[$myrow['study']][] = $myrow['symbol'];
   }
}
}

You should get an array like this ...
array("b2008" => array("A", "B", "C", "D"), "b2005" => array("A", "B", "E"))

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux