| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- include('../conn_mysqli.php');
- include('../phpMode/rcodeMap.php');
- $key = $_GET['key'];
- // 设置 $page 的默认值为1,并限定取值范围在1-10之间
- $page = isset($_GET['p']) ? max(1, min(10, intval($_GET['p']))) : 1;
- // 设置 $limit 的默认值为10,并限定取值范围在1-100之间
- $limit = isset($_GET['l']) ? max(1, min(100, intval($_GET['l']))) : 10;
- $offset = ($page - 1) * $limit;
- $parentSolutionType = 1;
- // 返回值设定
- header('Content-Type:text/json;charset=utf-8;');
- $resObj = array(
- 'rcode'=>Rcode_OK,
- 'data'=>"",
- 'msg'=>'ok'
- );
- if(!isset($_GET['key'])){
- $resObj['rcode'] = Rcode_NotParam;
- $resObj['data'] = "";
- $resObj['msg'] = "key is must set";
- echo json_encode($resObj);
- exit;
- }
- $conn = createConn();
- $sql = "SELECT news.id,news.remark,news.title as name,news.image,news.source_val as source,news.sourceType
- FROM mysql85931094_db.hfy_news as news ,mysql85931094_db.hfy_news_type as n_type
- WHERE news.type_id = n_type.type_id and n_type.parent_type = ? and n_type.type_key = ? limit ?,?";
- // 创建stmt
- $stmt = mysqli_prepare($conn, $sql);
- // 绑定
- mysqli_stmt_bind_param($stmt, "dsdd",$parentSolutionType,$key, $offset,$limit);
- mysqli_stmt_execute($stmt);
- $res = mysqli_stmt_get_result($stmt);
- while($row = mysqli_fetch_assoc($res)) { $rs[] = $row; }
- mysqli_close($conn);
- $resObj['data'] = $rs ;
- echo json_encode($resObj);
- ?>
|