PHP mysql_num_rows总是显示" 0"零

时间:2015-04-27 20:01:01

标签: php

api.php

中的此代码
    if(isset($_GET['cat_id']))
    {
            //$query="SELECT id,title,images,category,date,state FROM news WHERE category='".$_GET['cat_id']."' ORDER BY id DESC LIMIT 100";        
            //$resouter = mysql_query($query);

            $query="SELECT id,title,images,category,date,state FROM category c, news n WHERE c.category=n.category and c.id='".$_GET['cat_id']."' ORDER BY n.id DESC LIMIT 100";            
            $resouter = $db->query($query);

    }


    $set = array();

    $total_records =  $resouter->num_rows;
    if($total_records >= 1){

      while ($link = $resouter->fetch_array(MYSQLI_ASSOC)){
        $set['NewsApp'][] = $link;
      }
    }
     echo $val = str_replace('\\/', '/', json_encode($set,JSON_UNESCAPED_UNICODE));

但是当我跑到api.php?cat_id=1时,只显示[]这样的话。可以请别人帮帮我吗?

...问候

0 个答案:

没有答案