如何通过考虑表customer_stock中的两个条件来获得数量

时间:2016-05-12 09:40:45

标签: php mysql arrays json database

我遇到了php,mysql和json的问题 我无法通过选择两个条件从数据库中检索数据 我也附上了screenshot 我想通过考虑两个条件来检索表customer_stock中的数量:客户和名称

$line = $db->queryUniqueObject("SELECT * FROM stock_details  WHERE stock_name ='" . $_POST['stock_name1'] . "'");
$cost = $line->company_price;
$sell = $line->selling_price;
$stock_id = $line->stock_id;
$line = $db->queryUniqueObject("SELECT * FROM customer_stock WHERE name='" . $_POST['stock_name1'] . "'");

$stock = $line->quantity;

if ($line != NULL) {

    $arr = array("cost" => "$cost", "sell" => "$sell", "stock" => "$stock", "guid" => $stock_id);
    echo json_encode($arr);

} else {
    $arr1 = array("no" => "no");
    echo json_encode($arr1);
}

0 个答案:

没有答案