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 = array("a2008","b2005");
Then I try to produce the following structure (array of arrays):
$combinedArray = array(array('A','B','C','D'),array('A','B','E'));
Below is my php script. In the present solution the $combinedArray
includes only 'symbol' values for last iteration (where $myArray = "b2005").
How should I proceed? Thanks in advance for any suggestions.
Best, Andrej
$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)) {
$combinedArray[] = $myrow['symbol'];
}
}
}
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php