问题
I am struggling for an idea or logic to solve my issue. I am stuck now.
My issue is, I am getting the multiple member_id and sending to model to get the related records from the table and also to check the duration of each member if the duration is 2018-2019 then display the records of the next year 2019-2020 which is on another table.
I have to display the list like
Member one information
related records
Member two information
related records
and so on
Explanation in details
I have three tables, member, activity, and fees.
member table
m_id | name | email | mobile | type
1 | nbvg |as@gmail.com | 9876543212 | 1
2 | svfs |cd@gmail.com | 1233123121 | 2
3 | aasd |sv@gmail.com | 1233123121 | 2
4 | pokg |pk@gmail.com | 1233123121 | 2
activity table
r_id | m_id | duration | date_of_added
1 | 1 | 2018-2019 | 2018-04-01 07:01:16
2 | 2 | 2018-2019 | 2018-04-01 13:11:53
3 | 1 | 2019-2020 | 2019-02-02 02:15:45
4 | 3 | 2018-2019 | 2018-04-01 20:30:10
fees table
f_id | f_duration | fees1 | startCutoffDate | endCutoffDate
1 | 2018-2019 | 100 | 2019-02-01 | 2019-03-31
2 | 2019-2020 | 200 | 2019-04-01 | 2020-03-31
3 | 2020-2021 | 300 | 2020-04-01 | 2021-03-31
I am using a query to get the member id where type=2
. So I got output
m_id | name | email | mobile | type
2 | svfs |cd@gmail.com | 1233123121 | 2
3 | aasd |sv@gmail.com | 1233123121 | 2
4 | pokg |pk@gmail.com | 1233123121 | 2
Now I am passing the m_id
in the activity table to get the records. So I tried something like this in the controller.
$data['getSec']=$this->Access_model->getSec();//getting member where type=2
$secActivityData=[];
foreach ($data['getSec'] as $key => $sec_m_id) {
$secActivityData[]=$this->Access_model->getActivityData($sec_m_id->m_id)
}
$data['setActivityData'] = $secActivityData;
$this->load->view('member-profile',$data);
Model
public function getActivityData($getmemberId){
$getDetails = array('status'=>1,'approve'=>1,'m_id'=>$getmemberId);
$result = $this->db->where($getDetails)
->select('*')
->from('activity')
->group_by('m_id')
->order_by('date_of_added','DESC')
->get()
->result();
if($result)
{
foreach ($result as $key => $value) {
$membershipForTheYear=explode('-',$value->duration);
$addNextyear=$membershipForTheYear[1] + 1;
$activeBTN=$membershipForTheYear[1].'-'.$addNextyear;
}
$where = array('f_duration'=>$activeBTN);
$result = $this->db->where($where)
->from('fees')
->get()
->row();
if ($result) {
return $result;
}
else{
return 0;
}
}
else
{
return 0;
}
}
just noticed my model code, I am getting the member id and using member id I am getting the records and passing the duration to the IF condition to get the result.
Let's talk about view
$secUpcoming=$getSec;
foreach ($secUpcoming as $key => $secPersonalInfo) {?>
<!--Displaying personal information-->
$UpcomingActivity=$setActivityData;
if (!empty($UpcomingActivity)) {
foreach ($UpcomingclubMembership as $key => $value) {
$startCutoffDate=strtotime($value->clubFeesSec);
$endCutoffDate=strtotime($value->clubFeesSec);
?>
<!--display activity records with upcoming year fees-->
<?php }}else{echo"no data";}
}?>
Would you help me out in this issue?
来源:https://stackoverflow.com/questions/54840298/how-to-get-the-records-of-multiple-ids-along-with-next-year-fees-data-and-displa