Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php CodeIgniter中的字母列表_Php_List_Codeigniter - Fatal编程技术网

Php CodeIgniter中的字母列表

Php CodeIgniter中的字母列表,php,list,codeigniter,Php,List,Codeigniter,想知道如何使用CodeIgniter实现这一点吗? 非常感谢您的帮助 谢谢。没有内置函数来完成此操作。您必须循环执行sql查询才能执行此操作 Select * from table order by field asc foreach ( $result as $thing ) { if ( $thing['name'][0] != $first_letter) { echo '<h2>' . $thing['name'][0] . '</h2&g

想知道如何使用CodeIgniter实现这一点吗?

非常感谢您的帮助


谢谢。

没有内置函数来完成此操作。您必须循环执行sql查询才能执行此操作

Select * from table order by field asc

foreach ( $result as $thing ) {

    if ( $thing['name'][0] != $first_letter) {
        echo '<h2>' . $thing['name'][0] . '</h2>';
        $first_letter = $thing['name'][0];
    }
    echo $result['thing'];

}
按字段asc从表顺序中选择*
foreach($result as$thing){
如果($thing['name'][0]!=$first\u字母){
回显'.$thing['name'][0].';
$first_letter=$thing['name'][0];
}
echo$result['thing'];
}
这只是一个粗略的例子…永远不要像那样回显html

  • //模型中 公共函数alphaDirectory(){ //查询数据 $sql=“按列名称从表顺序选择子字符串(列名称,1,1)作为字母、列名称、列链接”; $query=$this->db->query($sql); $columnByName=“”
  • foreach($query->result()作为$row) { $columnByName[$row->letter][]=数组($row->column\u name,$row->column\u链接); } 返回$columnByName; }

  • //在控制器中调用模型并将返回数组传递给视图

  • 鉴于
      $V){ echo“
    • ”.strtoupper($k)。“
      • ”; foreach($v作为$links){ 回声“
      • ”$links[0]。“
      • ”; } 回音“
      ” } ?>

  • 使用css进行装饰,以获得与您所看到的完全匹配