MYSQL:从一列中选择多个值

时间:2016-01-26 08:01:20

标签: php mysql

我有下表:

name -  catridge_type - department - date -     quantity
--------------------------------------------------------
Ak   -  Hp 305A Cyan  - IT         - 2016-01-13 - 5
Ad   -  Hp 508A Black - Hr         - 2016-02-13 - 6

我有以下select语句:

$query= "SELECT catridge_type, quantity FROM catridge_details WHERE quantity > 0 ";

我的select语句将catridge_type返回为null,但将quantity作为相应的值。

请协助。

附加代码:

$result = $db->query($query);
if(!$result) { die('Error getting Catridge types ['.$db->error.']' );}
else{
    //create an array to store the data
    $catridge_array = array();
    while ($row = $result->fetch_assoc()) {
        array_push($catridge_array, new available_catridges($row['catridges'], $row['quantity']));
            }

    header('Content-Type: application/json');
    echo json_encode($catridge_array);
        } 

1 个答案:

答案 0 :(得分:0)

$row['catridges']不存在。试试$row['catridge_type']