Here is my problem,
I need to show all the people with birthdays with the selected month, I already got on how to put the data on the specific, table cells, the only problem is that the data is also appearing on other tables cells which it is not intended. On the figure below Ori Hendricks
must only be on 2
but it appears on other cells.
Here is the data for the calendar
Array
(
[2] => Array
(
[0] => Nomlanga Bentley**81
[1] => Ori Hendricks**325
)
[5] => Array
(
[0] => Rina Nash**161
)
[10] => Array
(
[0] => Gary Mullins**252
)
[12] => Array
(
[0] => Nissim Donovan**207
)
[13] => Array
(
[0] => Harper Trevino**380
)
[14] => Array
(
[0] => Sacha Arnold**167
[1] => Wade Hughes**322
[2] => Brennan Long**3
)
[15] => Array
(
[0] => Gary Hart**290
)
[21] => Array
(
[0] => Alisa Bowman**201
)
[22] => Array
(
[0] => Dustin Meyers**330
)
[26] => Array
(
[0] => Ifeoma Swanson**331
)
[28] => Array
(
[0] => McKenzie Norton**327
[1] => Asher Rasmussen**47
)
[29] => Array
(
[0] => Branden Conway**7
[1] => Luke Sullivan**176
)
[30] => Array
(
[0] => Slade Moon**16
)
)
Iv'e created a MY_calendar
class and created my own generator,here is the relevant code for showing the data on the cells
if (isset($data[$day]))
{
// Cells with content
$temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content'];
if(is_array($data[$day]))
{
foreach($data[$day] as $k => $v)
{
$name = substr($v,0,strpos($v,'**'));
$student_enrollment_id = substr($v,strpos($v,'**')+2);
$data_formatted[$k] = '<a href="'.site_url('profile/student/'.$student_enrollment_id).'" target="_blank" class="btn btn-mini">'.trim($name).'</a>';
}
$data_from_array = implode('',$data_formatted);
$out .= str_replace('{day}', $day, str_replace('{content}', $data_from_array, $temp));
}else{
$out .= str_replace('{day}', $day, str_replace('{content}', $data[$day], $temp));
}
}
else
{
// Cells with no content
$temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content'];
$out .= str_replace('{day}', $day, $temp);
}
i don't have any other idea how to do this, please help.
The issue is happening because the array indexes are still holding the values from the last loop.
Just make this slight change in MY_calendar class code snippet you have pasted above:
<?php
if (isset($data[$day]))
{
// Cells with content
$temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_content_today'] : $this->temp['cal_cell_content'];
if(is_array($data[$day]))
{
foreach($data[$day] as $k => $v)
{
$name = substr($v,0,strpos($v,'**'));
$student_enrollment_id = substr($v,strpos($v,'**')+2);
$data_formatted[$k] = '<a href="'.site_url('profile/student/'.$student_enrollment_id).'" target="_blank" class="btn btn-mini">'.trim($name).'</a>';
}
$data_from_array = implode('',$data_formatted);
$out .= str_replace('{day}', $day, str_replace('{content}', $data_from_array, $temp));
$data_formatted = array_fill(0,count($data_formatted), null); // line added to reset the values in previous loop
}else{
$out .= str_replace('{day}', $day, str_replace('{content}', $data[$day], $temp));
}
}
else
{
// Cells with no content
$temp = ($is_current_month == TRUE AND $day == $cur_day) ? $this->temp['cal_cell_no_content_today'] : $this->temp['cal_cell_no_content'];
$out .= str_replace('{day}', $day, $temp);
}
This should fix the issue.