大家好我想在一个表中显示数据数组。但主要任务是我需要显示一个主管下的所有用户,他们可能/可能没有尝试过测试。我正在使用if else条件在控制器,但我得到像
这样的错误消息:未定义索引:状态和消息:未定义索引: submittimestamp
下面是我的代码
控制器:
if ($supervisor) {
$users_query="SELECT u.* ,v.value FROM usr_data u, udf_text v WHERE u.usr_id != 6 AND u.usr_id = v.usr_id " . $supervisor_condition . " GROUP BY u.usr_id";
// echo $users_query;
$user_records = $this->base_model->executeSelectQuery($users_query);
$final_dataa = [];
foreach ($user_records as $user) {
$user=(object)$user;
$user_test=" SELECT u.*,o.title,ta.*,tpr.workingtime, tpr.pass, tpr.tstamp, tpr.points, tpr.maxpoints, tm.minimum_level, tcr.mark_official,(tcr.reached_points/tcr.max_points)*100 as result,v.value,ta.submittimestamp,tcr.mark_official FROM usr_data u, object_data o,tst_tests tt,tst_active ta,tst_pass_result tpr, tst_result_cache tcr,udf_text v, tst_mark tm WHERE u.usr_id != 6 AND u.usr_id=ta.user_fi AND tt.obj_fi=o.obj_id AND v.usr_id=u.usr_id AND ta.test_fi=tt.test_id AND tt.test_id = tm.test_fi AND tcr.active_fi=ta.active_id AND tm.passed = 1 AND ta.active_id=tpr.active_fi AND tcr.active_fi=ta.active_id AND v.field_id='2' AND ta.user_fi = $user->usr_id GROUP by ta.submittimestamp";
// echo $user_test;
$tst_records=$this->base_model->executeSelectQuery($user_test);
if (count($tst_records)) {
foreach ($tst_records as $tst) {
$tst=(object)$tst;
$dta['usr_id'] = $user->usr_id;
$dta['firstname'] = $user->firstname;
$dta['matriculation'] = $user->matriculation;
$dta['approve_date'] = $this->udfTextData(1, $user->usr_id);
$dta['department'] = $user->department;
$dta['job_title'] = $this->udfTextData(6, $user->usr_id);
$dta['submittimestamp'] = $tst->submittimestamp;
$dta['test_title'] = $tst->title;
$dta['division'] = $tst->value;
$mark_official = $tst->mark_official;
if ($mark_official == "passed" || $mark_official == "Passed" || $mark_official == "PASSED") {
$result_status = '<span class="label label-primary"> Completed </span>';
$completed = TRUE;
} else {
$result_status = '<span class="label label-danger"> Failed </span>';
$failed = TRUE;
}
$dta['status'] = $result_status;
$final_dataa[] = $dta;
}
}
else{
$dta['usr_id'] = $user->usr_id;
$dta['firstname'] = $user->firstname;
$dta['matriculation'] = $user->matriculation;
$dta['approve_date'] = $this->udfTextData(1, $user->usr_id);
$dta['department'] = $user->department;
$dta['job_title'] = $this->udfTextData(6, $user->usr_id);
$dta['test_title'] = $user->title;
$dta['division'] = $user->value;
$final_dataa[] = $dta;
}
}
}
$dataa['recordss'] = $final_dataa;
$this->load->view('supervisor', $dataa);
我正在使用if else条件,如果用户测试的其他不是那样的.below是我的视图代码
查看:
<h3> Skill Matrix Report Process Based Training Record in LMS </h3>
<hr>
<?php $uniq_rec = array_unique($recordss,SORT_REGULAR);
// var_dump($uniq_rec);
$uniq_name = array_unique(array_column($recordss, 'firstname'));
$uniq_test = array_unique(array_column($recordss, 'test_title'));
?>
<table class="table" id="myTable">
<thead>
<tr>
<th>Employe NO</th>
<th>Employe Name</th>
<th>Date Joined</th>
<th>division</th>
<th>department</th>
<th>jobtitle</th>
<?php
foreach ($uniq_test as $row) {
?>
<th><?php echo $row?></th>
<?php
}
?>
</tr>
</thead>
<tbody>
<?php
foreach ($uniq_rec as $row) {
$row = (object)$row;
// var_dump($row);
$date_joined_y = substr($row->approve_date,0,4);
$date_joined_m = substr($row->approve_date,4,2);
$date_joined_d = substr($row->approve_date,6,2);
$date_joined = $date_joined_d."-".$date_joined_m."-".$date_joined_y;
?>
<tr>
<td><?php echo ucfirst($row->matriculation); ?></td>
<td><?php echo $row->firstname?></td>
<td> <?php echo ucfirst($date_joined); ?></td>
<td><?php echo ucfirst($row->division); ?></td>
<td><?php echo ucfirst($row->department); ?></td>
<td><?php echo ucfirst($row->job_title); ?></td>
<?php
foreach ($uniq_test as $uniq) {;
$status = "";
foreach ($recordss as $rec) {
if($uniq == $rec['test_title'] && $rec['firstname'] == $row->firstname){
echo "<td>".$rec['status'].$rec['submittimestamp']."</td>";
$status = "true";
}
}
if($status != "true"){
echo "<td></td>";
}
$status = "";
}
?>
但主要任务是我需要显示所有尝试测试的用户,但这些用户属于一名主管 submittimestamp但主要任务是我需要显示所有尝试测试的用户,但是那些用户在一个Supervisor下。我在控制器中使用if else条件但是收到错误
消息:未定义索引:状态和消息:未定义索引: submittimestamp