function getlist() { $page = 1; $size = 15; $pctype = 1; if (isset($_GET['pctype'])) { $pctype = $_GET['pctype']; } if ($_GET['page'] != "") { $page = $_GET['page']; } if ($_GET['size'] != "") { $size = $_GET['size']; } import("ORG.Util.Page1"); $proOb = new ProductModel(); $sum = $proOb->getProductCount(" pctype={$pctype}"); $pageOb = new Page($page, $size, $sum); $start = $pageOb->getStartStr(); //$arr=$proOb->getProductList($start,10); //$pTypeOb=new producttypeModel; //$typearr=$pTypeOb->getListType(); //搜索相关 $title = $_GET['title']; $type = $_GET['type']; $sontype = $_GET['sontype']; $price = $_GET['price']; $status = $_GET['status']; $where = " (status=1 or status=2)" . " and pctype={$pctype} "; if (!empty($title)) { $where .= " and title like '%{$title}%'"; } if (!empty($type)) { $where .= " and type={$type}"; } if (!empty($sontype)) { $where .= " and sontype={$sontype}"; } if (!empty($status)) { $where .= " and status='{$status}'"; } if (!empty($price)) { switch ($price) { case 1: $where .= " and price<1000"; break; case 2: $where .= " and price between 1000 and 2000"; break; case 3: $where .= " and price between 2000 and 3000"; break; case 4: $where .= " and price between 3000 and 4000"; break; case 5: $where .= " and price>4000"; break; default: $where .= ""; } } $arr = $proOb->getProductList($start, $size, $where); //var_dump($arr); $pageStr = $pageOb->getPagestr1(3); $arr = array('page' => $pageStr, 'data' => $arr); //var_dump($data); $data = json_encode($arr); echo $data; }