Return array in php
So, I'm filling an array with data from a database using a query. I want
to know what is the correct way to return the whole array. Note that the
code has been edited to ask this specific question, so it may have syntax
or other errors. I only want to know if im returning the array correctly.
Thanks!
function getDailyGraph($membership, $selectedMonth){
$sql = "SELECT rate_amount AS payment, DAY(date) AS day FROM
payments WHERE membership_id = ".$membership.
" AND MONTH(date) = ".$selectedMonth." ORDER BY day";
$query = $db->query($sql);
$days = array();
while ($payment = mysql_fetch_array($query)) {
$days[] = $payment['payment'];
}
return $days;
}
This is how i call the function:
$daily = $member->getDailyGraph(4,9);
The function code is inside class Members instanced as $member.
No comments:
Post a Comment