如何让数据表在codeigniter中显示大写

时间:2017-07-20 20:05:42

标签: php codeigniter

我无法弄清楚如何获取数据表以在表格中显示大写字母。我需要名字和供应商是大写的。我确实将onblur="this.value=this.value.toUpperCase()"添加到添加表单中,但是当我点击提交时,表格显示全部小写的数据。所以我想我可以强制数据表以大写形式显示它。我从我的控制器发布了部分代码。任何帮助将不胜感激。

public function ajax_list()
    {
        $list = $this->visitor_log_list->get_datatables();
        $data = array();
        $no = $_POST['start'];
        foreach ($list as $visitor_log_list) {
            $no++;
            $row = array();
            $row[] = $visitor_log_list->date;
            $row[] = $visitor_log_list->name;
            $row[] = $visitor_log_list->vendor;
            $row[] = $visitor_log_list->department;
            $row[] = $visitor_log_list->contact_person;
            $row[] = $visitor_log_list->expected_arrival_time;

            //add html for action
            $row[] = '<a class="btn btn-sm btn-link " href="javascript:void()" title="Edit" onclick="edit_visitor_log('."'".$visitor_log_list->id."'".')"><i class="glyphicon glyphicon-pencil"></i> Edit</a>
                  <a class="btn btn-sm text-warning" href="javascript:void()" title="Hapus" onclick="delete_visitor_log('."'".$visitor_log_list->id."'".')"><i class="glyphicon glyphicon-trash"></i> Delete</a>';

            $data[] = $row;
        }

        $output = array(
                        "draw" => $_POST['draw'],
                        "recordsTotal" => $this->visitor_log_list->count_all(),
                        "recordsFiltered" => $this->visitor_log_list->count_filtered(),
                        "data" => $data,
                );
        //output to json format
        echo json_encode($output);
    }

1 个答案:

答案 0 :(得分:1)

将字符串包装在strtoupper()

<?php
    public function ajax_list() {
        $list = $this->visitor_log_list->get_datatables();
        $data = array();
        $no   = $_POST['start'];
        foreach ($list as $visitor_log_list) {
            $no++;
            $row    = array();
            $row[]  = $visitor_log_list->date;
            $row[]  = strtoupper($visitor_log_list->name);
            $row[]  = strtoupper($visitor_log_list->vendor);
            $row[]  = $visitor_log_list->department;
            $row[]  = $visitor_log_list->contact_person;
            $row[]  = $visitor_log_list->expected_arrival_time;
            //add html for action
            $row[]  = '<a class="btn btn-sm btn-link " href="javascript:void()" title="Edit" onclick="edit_visitor_log(' . "'" . $visitor_log_list->id . "'" . ')"><i class="glyphicon glyphicon-pencil"></i> Edit</a>
                  <a class="btn btn-sm text-warning" href="javascript:void()" title="Hapus" onclick="delete_visitor_log(' . "'" . $visitor_log_list->id . "'" . ')"><i class="glyphicon glyphicon-trash"></i> Delete</a>';
            $data[] = $row;
        }
        $output = array(
            "draw" => $_POST['draw'],
            "recordsTotal" => $this->visitor_log_list->count_all(),
            "recordsFiltered" => $this->visitor_log_list->count_filtered(),
            "data" => $data
        );
        //output to json format
        echo json_encode($output);
    }
?>