doucong6884 2014-04-09 13:37
浏览 46

从表数据库获取数据的格式数组

i have this code

$Query = mysql_query("Select*from mbulan");
while ($row = mysql_fetch_array($Query, MYSQL_ASSOC)) {
$items = array($row['id']=>$row['bulan']);
foreach ($items as $key=>$value) {
        echo json_encode(array("$value"));}
}

and the output something like this :

["January"]["Fabruary"]["Maret"]["April"]["Mei"]["Juni"]

but i wan change the output like :

["January","February","Maret","April","Mei","Juni"]

what should i do for the code and where is the code must be change it ?

  • 写回答

2条回答 默认 最新

  • dpwle46882 2014-04-09 13:43
    关注

    You can use the following code ..

    $Query = mysql_query("SELECT * FROM mbulan");
    $item = array();
    while ($row = mysql_fetch_array($Query, MYSQL_ASSOC)) {
        $items[] = $row['bulan'];
    }
    
    echo json_encode($items);
    

    Feel free to ask any questions.

    评论

报告相同问题?

悬赏问题

  • ¥15 武汉岩海低应变分析软件,导数据库里不显示波形图
  • ¥15 CreateBitmapFromWicBitmap内存释放问题。
  • ¥30 win c++ socket
  • ¥30 CanMv K210开发板实现功能
  • ¥15 C# datagridview 栏位进度
  • ¥15 vue3页面el-table页面数据过多
  • ¥100 vue3中融入gRPC-web
  • ¥15 kali环境运行volatility分析android内存文件,缺profile
  • ¥15 写uniapp时遇到的问题
  • ¥15 vs 2008 安装遇到问题