Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.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 在crud中从mysql数据库获取列_Php_Grocery Crud - Fatal编程技术网

Php 在crud中从mysql数据库获取列

Php 在crud中从mysql数据库获取列,php,grocery-crud,Php,Grocery Crud,我想用crud中数据库中修改的列数据创建一个下拉列表。我的代码如下 $this->db->select($column); $temp = $this->db->get($table); $temp1 = array(); foreach ($temp as $row) { $temp1[] = $row[$column]; } 但是这个代码不起作用。我收到错误未定义的索引$column错误。我在哪里犯错?我不能使用crudset\u relationapi,因

我想用crud中数据库中修改的列数据创建一个下拉列表。我的代码如下

$this->db->select($column);
$temp = $this->db->get($table);
$temp1 = array();
foreach ($temp as $row)
{
    $temp1[] = $row[$column];
}

但是这个代码不起作用。我收到错误
未定义的索引$column
错误。我在哪里犯错?我不能使用crud
set\u relation
api,因为我需要在将数据库列数据传递到下拉列表之前修改它。

我的代码出错了。食品杂货积垢的工作代码如下

public function get_column($table, $column, $condition=null, $value=null)
{
    $this->db->select($column);
    if ($condition != null)
    {
        $this->db->where($condition, $value);
    }
    $temp = $this->db->get($table);

    $temp_array = array();
    foreach ($temp->result() as $row)
    {
        $temp_array[] = $row->$column;
    }
    return $temp_array;
}