【发布时间】:2021-01-18 11:23:45
【问题描述】:
我需要编辑或删除GROUP_CONCAT() 上的每个数据。我的主要问题是如何传递每个数据的 id。
如果我将光标添加到“kiswahili”或“physics”上的这些主题,我们可以预期鼠标光标在该主题上会随着该主题的 id 链接在编辑页面或删除页面上移动。
这是我的主题模型代码:
public function set_subject_get($idSchool){
$this->db->select('standards_name, GROUP_CONCAT(subject_name SEPARATOR " || ") as subject,
GROUP_CONCAT(subject_id) as subjectid');
$this->db->from('subjects');
$this->db->join('standards', 'standards_id = subject_standard_id');
$this->db->where('subject_school_id', $idSchool);
$this->db->group_by('subject_standard_id');
$query = $this->db->get();
return $query->result();
}
在查看页面我有这样的代码:
if($subjects > 0){
$n = 1;
foreach($subjects as $data){
?>
<tr>
<th scope="row"><?php echo $n;?></th>
<td><?php echo $data->standards_name; ?></td>
<td><?php echo $data->subject; ?></td>
</tr>
<?php
$n++;
}
}else{
//...
主题表包含这些信息
请你帮我继续这部分谢谢大家
【问题讨论】:
标签: php mysql codeigniter grouping group-concat