Home > Backend Development > PHP Tutorial > Detailed explanation of examples of pointers

Detailed explanation of examples of pointers

零下一度
Release: 2023-03-10 17:56:02
Original
1195 people have browsed it
//1.接收url里面的内容
Copy after login
 public function newstype(Request $request)
    {

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

 

a. 要有    把$news里面的nowtime用$mm替换....
Copy after login
$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']);

    }

}
Copy after login

 

b.Append $vvv['ncommtent] to $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']}";

                        }
Copy after login

  //3. Output json

 $data = array(

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

 

The above is the detailed content of Detailed explanation of examples of pointers. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template