这是我的代码,在查询http://localhost/business/php/productList.php?class=first&id=1时一直显示[]
<?php
include "server.php";
$class = $_GET['class'];
$id = $_GET['id'];
$sql = "";
// 全部
if($class == "all"){
$sql = "select * from t_product";
}
// 积分
if($class == "integral"){
$sql = "select * from t_product where integral!=0";
}
// 一级分类
if($class == "first"){
$sql = "select * from t_product,t_product_type where t_product.product_type_id = t_product_type.id and t_product_type.pId = '{$id}'";
}
// 二级分类
if($class == "second"){
$sql = "select * from t_product where product_type_id ='{$id}'";
}
$r = mysqli_query($mysqli,$sql);
$arr = array();
$i = 0;
while($row = mysqli_fetch_array($r)){
$arr[$i] = $row;
$i++;
}
echo json_encode($arr);
?>