A detailed example of pointers

Source: Internet
Author: User
1. Receive the contents of the URL
Public Function Newstype (Request $request)    {        $url = $request->url ();        $isfirst = input (' Isfirst ');        $uid = input (' token ');   }

 

A. To have the    nowtime inside the $news replaced with $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) {    //News comment    $ 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. 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 & $mm 2) {                        //News comment                        $ncommtent = db::query ("Select Ncommtent from  newreview  where nid = {$mm 2[' nid ']} ");                        foreach ($ncommtent as $VVV) {                            $mm 2[' ncommtent '] = "{$vvv [' ncommtent ']}";                        }

3. Output JSON

$data = Array (                ' code ' = = 0,                ' msg ' = +                    Array (                        ' news ' = ' $news,                        ' newsimg ' + $newsimg ,                        ' comments ' = $comments                    )            );            Return Json_encode ($data, N.);  JSON, and does not appear garbled

  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.