For my admin page I created a graph which shows my registerd members per week for 2016 and 2015.
The Mysql query is working fine but when in a certain week no members has registerd the graph just moves one position to the left.
Mysql query
SELECT WEEKOFYEAR( date) AS weekno, COUNT( 1 ) AS signup,
SUBDATE( date, INTERVAL WEEKDAY( date) DAY ) AS date_of_week
FROM members
WHERE YEAR( date) = '".$year."'
GROUP BY WEEKOFYEAR( date);
What I (asume) need to do is check the array for missing weekno and if so fill the (new?) array with the missing weekno and add value 0 to signups.
foreach($oMember as $val) {
$signups = $val[signups];
$weekno = $val[weekno];
if(empty($val)) { $val = '0'; }
}
This is what I tried but stil without any good working solution, also array search from Halil:
array_search(strtolower($search), array_map('strtolower', $array));
Hope someone can help.
Best regards. Jan