Hey guys, I hardly ever work with Foreach(), but I've read over the procedures for it and I cant seem to figure out why this is only returning a single record. I could be way off base on the proper use here. Note this is test code for trying to figure out whats going on, so none of the function elements are being used, but it illustrates my problem.
The array is storing the entire table with 18 columns and 3 rows.
Here is the function being called:
[CODE=PHP]function topPilots($star tTime, $endTime, $orderBy) // Retrieves list of pilots order
{
$sql = "SELECT * FROM completedFlight s";
$result = mysql_query($sq l);
$array = mysql_fetch_arr ay($result, MYSQL_ASSOC);
return $array;
}[/CODE]
Here is the function in use:
[CODE=PHP]$array = topPilots($this MonthStart, time(), "SUM(cargo) ");
foreach($array as $key => $value)
{
echo $key.": ".$value." <br />";
}[/CODE]
The array is storing the entire table with 18 columns and 3 rows.
Here is the function being called:
[CODE=PHP]function topPilots($star tTime, $endTime, $orderBy) // Retrieves list of pilots order
{
$sql = "SELECT * FROM completedFlight s";
$result = mysql_query($sq l);
$array = mysql_fetch_arr ay($result, MYSQL_ASSOC);
return $array;
}[/CODE]
Here is the function in use:
[CODE=PHP]$array = topPilots($this MonthStart, time(), "SUM(cargo) ");
foreach($array as $key => $value)
{
echo $key.": ".$value." <br />";
}[/CODE]
Comment