Re: [PHP] SELECT into array of arrays

2008-12-03 Thread Yeti
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;$icount($myArray);$i++) { $sql = SELECT study,symbol FROM test WHERE study IN ('$myArray[$i]'); $result =

Re: [PHP] SELECT into array of arrays

2008-12-03 Thread Yeti
Correcting myself now .. $myArray = array('b2005', 'b2008'); $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))

Re: [PHP] SELECT into array of arrays

2008-12-03 Thread Andrej Kastrin
Thanks Yeti, it works. Best, Andrej Yeti wrote: Correcting myself now .. $myArray = array('b2005', 'b2008'); $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)) {

Re: [PHP] SELECT into array of arrays

2008-12-03 Thread ceo
I actually would do more like: $myArray[$study][$symbol] = true; No need to call in_array. Probably won't matter, really, but it's a good practice for when you end up doing the same kind of code for an array with thousands of elements. -- PHP General Mailing List

Re: [PHP] SELECT into array of arrays

2008-12-03 Thread Yeti
And yet another thing i have overseen in my statement .. If you remove the first for loop, also change the sql query. But I'm sure you saw that already NEW QUERY: $sql = SELECT study,symbol FROM test WHERE study IN ('.implode(', ', $myArray).'); -- PHP General Mailing List (http://www.php.net/)

[PHP] SELECT into array of arrays

2008-12-02 Thread Andrej Kastrin
Dear all, I have a MySQL table 'test' which includes two columns: 'study' and 'symbol': study symbol a2008 A a2008 B a2008 C a2008 D b2005 A b2005 B b2005 E Using POST variable I passed 'study' values into $myArray: // $myArray is variable length; used only two values in example $myArray =