The statement returncompletes your loop and exits the function.
To get all the values, add them to the array in a loop and return the array. Like this:
$results = array();
while ($result = mysql_fetch_array($data)) {
$results[] = $result;
}
return $results;
on the side that receives the array
$msgArray = mail_detail($mail_detail);
foreach($msgArray as $msg) {
}
To add, a function can only return once (except in special circumstances that you should not worry about). Therefore, at the first call to the return statement, a value is returned and completed.
This feature returncan often be used to your advantage. For instance:
function doSomething($code = NULL)
{
if ($code === NULL) {
return false;
}
writeToDb($code);
}