没有标头的PHP查询数组(使用MySQL数据库的CI)

时间:2018-04-24 18:16:36

标签: php codeigniter

大家好,我对使用MySQL数据库查询PHP有一些疑问。

我有像这样的表名test2

testid  asd
1       A
2       B
3       C
4       D

然后我有这样的查询

public function m_get_wer() {
    $sql = "SELECT `asd` FROM test2";
    $data = $this->db->query($sql)->result_array();
    return $data;
}

当我在该查询中使用print_r时,结果如下

Array ( [0] => Array ( [asd] => A ) [1] => Array ( [asd] => B ) [2] => Array ( [asd] => C ) [3] => Array ( [asd] => D ) )

但我需要的结果是这样的

Array ( [0] => A [1] => B [2] => C [3] => D )

我怎么能得到这样的结果。感谢。

1 个答案:

答案 0 :(得分:0)

希望这会对你有所帮助:

<!-- Include Required Prerequisites -->
<script type="text/javascript" src="//cdn.jsdelivr.net/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/momentjs/latest/moment.min.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/bootstrap/3/css/bootstrap.css" />

<!-- Include Date Range Picker -->
<script type="text/javascript" src="//cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.js"></script>
<link rel="stylesheet" type="text/css" href="//cdn.jsdelivr.net/bootstrap.daterangepicker/2/daterangepicker.css" />

输出将是:

<div class="container">
    <div class="well">
      <h1><span class="glyphicon glyphicon-calendar"></span></h1>
        <h3>Choose Your Dates</h3>
         <input type="text" id="datepicker"  value="01/01/2015 - 01/31/2015"/>                  
    </div>
</div>