首頁  >  文章  >  後端開發  >  關於指標的實例詳解

關於指標的實例詳解

零下一度
零下一度原創
2017-06-26 15:34:401184瀏覽
//1.接收url里面的内容
 public function newstype(Request $request)
    {

        $url = $request->url();
        $isfirst = input('isfirst');
        $uid = input('token');
   }

 

a. 要有    把$news里面的nowtime用$mm替换....
$news = Db::query('select news.nid,news.ntitle,news.nauthor,news.reviewnum,news.nowtime,news.iscollect,newreview.ncommtent from news,newreview WHERE news.nid=newreview.nid');
foreach($news as &$mm){
    //新闻评论
    $ncommtent = Db::query("select ncommtent from  newreview  where nid = {$mm['nid']}");
    foreach($ncommtent as $vvv){
        $mm['ncommtent'] = "{$vvv['ncommtent']}";

    }
    $nowtime = Db::query('select nowtime from  news ');
    foreach($nowtime as $n){
        $mm['nowtime'] = date("Y-m-d H:i:s", $n['nowtime']);

    }

}

  

b.把$vvv['ncommtent]追加到$new 裡面

# #
   $news = Db::query("select nid,ntitle,nauthor,reviewnum ,nowtime,iscollect from  news  where nsid = '{$ntid}' limit 6,6");
                    foreach($news as &$mm2){
                        //新闻评论
                        $ncommtent = Db::query("select ncommtent from  newreview  where nid = {$mm2['nid']}");
                        foreach($ncommtent as $vvv){
                            $mm2['ncommtent'] = "{$vvv['ncommtent']}";

                        }

  //3.輸出json

 $data = array(

                'code' => 0,
                'msg' =>
                    array(
                        'news' => $news,
                        'newsimg' => $newsimg,
                        'comments' => $comments
                    )
            );
            return json_encode($data,256);  //转json,并且不出现乱码

  

#

以上是關於指標的實例詳解的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn