Hero for help! How does Thinkphp output specified value data?

Source: Internet
Author: User
Hero for help! How does Thinkphp output specified data! The items table has a cate_id field. I only want to output data with cate_id = 11. what should I do? I have read a lot of information on the Internet, and I have also read Thinkphp development documentation. I have no such introduction and asked for help.
I personally think it is mainly $ item_mod = m ("items"); this section decides to output data, but how to output only the data at the time of cate_id = 11 please help me!
 _mod = d( "items" );        $this->_cate_mod = d( "items_cate" );    }    public function index( )    {        $month = mktime( 0, 0, 0, date( "m" ), 1, date( "Y" ) );        $sign_log_mod = m( "sign_log" );        $map['uid'] = $this->visitor->info['id'];        $map['sign_date'] = array(            "egt",            $month        );        $sign_info = $sign_log_mod->field( "id,uid,username,sign_date" )->where( $map )->select( );        foreach ( $sign_info as $info )        {            $day = date( "d", $info['sign_date'] );            $sign[$day] = $info;        }        $order = "ordid asc ";        $sort = $this->_get( "sort", "trim", "hot" );        $status = $this->_get( "status", "trim", "all" );        switch ( $sort )        {        case "new" :            $order .= ", coupon_start_time DESC";            break;        case "price" :            $order .= ", price DESC";            break;        case "hot" :            $order .= ", volume DESC";        }        switch ( $status )        {        case "all" :            $where['status'] = "underway";            break;        case "underway" :            $where['status'] = "underway";            break;        case "sellout" :            $where['status'] = "sellout";        }        $where['pass'] = "1";        $index_info['sort'] = $sort;        $index_info['status'] = $status;        $page_size = c( "ftx_index_page_size" );        $p = $this->_get( "p", "intval", 1 );        $index_info['p'] = $p;        $start = $page_size * ( $p - 1 );        $item_mod = m( "items" );        $items_list = $item_mod->where( $where )->order( $order )->limit( $start.",".$page_size )->select( );        $items = array( );        foreach ( $items_list as $key => $val )        {            $items[$key] = $val;            $items[$key]['class'] = $this->_mod->status( $val['status'], $val['coupon_start_time'], $val['coupon_end_time'] );        }        f( "items_list", $items );        $this->assign( "items_list", $items );        $this->assign( "index_info", $index_info );        $count = $item_mod->where( $where )->count( );        $pager = $this->_pager( $count, $page_size );        $this->assign( "page", $pager->fshow( ) );        $this->assign( "total_item", $count );        if ( FALSE === ( $cate_list = f( "cate_list" ) ) )        {            $cate_list = d( "items_cate" )->cate_cache( );        }        $this->assign( "cate_list", $cate_list );        $item_comment_mod = m( "items_comment" );        $comm_map['status'] = "1";        $comment_list = $item_comment_mod->where( $comm_map )->order( "add_time DESC" )->limit( "0,10" )->select( );        $this->assign( "comment_list", $comment_list );        $this->assign( "nav_curr", "shijiu" );        $this->_config_seo( c( "ftx_seo_config.index" ) );        $this->display( );    }    public function so( )    {        $sort = $this->_get( "sort", "trim", "hot" );        $status = $this->_get( "status", "trim", "all" );        $cid = $this->_get( "cid", "trim" );        $k = $this->_get( "k", "trim" );        $order = "ordid asc ";        switch ( $sort )        {        case "new" :            $order .= ", coupon_start_time DESC";            break;        case "price" :            $order .= ", price DESC";        }        switch ( $status )        {        case "all" :            $where['status'] = "underway";            break;        case "underway" :            $where['status'] = "underway";            break;        case "sellout" :            $where['status'] = "sellout";        }        $where['title'] = array(            "like",            "%".$k."%"        );        $this->assign( "k", $k );        if ( $cid )        {            $id_arr = $this->_cate_mod->get_child_ids( $cid, TRUE );            $map['cate_id'] = array(                "IN",                $id_arr            );            $spid = $this->_cate_mod->where( array(                "id" => $cate_id            ) )->getField( "spid" );            if ( $spid == 0 )            {                $spid = $cid;            }            else            {                $spid .= $cid;            }            $this->assign( "cid", $cid );        }        $where['pass'] = "1";        $index_info['sort'] = $sort;        $index_info['status'] = $status;        $page_size = c( "ftx_index_page_size" );        $p = $this->_get( "p", "intval", 1 );        $index_info['p'] = $p;        $start = $page_size * ( $p - 1 );        $item_mod = m( "items" );        $items_list = $item_mod->where( $where )->order( $order )->limit( $start.",".$page_size )->select( );        $items = array( );        foreach ( $items_list as $key => $val )        {            $items[$key] = $val;            $items[$key]['class'] = $this->_mod->status( $val['status'], $val['coupon_start_time'], $val['coupon_end_time'] );        }        f( "items_list", $items );        $this->assign( "items_list", $items );        $this->assign( "index_info", $index_info );        $count = $item_mod->where( $where )->count( );        $pager = $this->_pager( $count, $page_size );        $this->assign( "page", $pager->fshow( ) );        $this->assign( "total_item", $count );        if ( FALSE === ( $cate_list = f( "cate_list" ) ) )        {            $cate_list = d( "items_cate" )->cate_cache( );        }        $this->assign( "cate_list", $cate_list );        $item_comment_mod = m( "items_comment" );        $comment_list = $item_comment_mod->order( "id DESC" )->limit( "0,10" )->select( );        $this->assign( "comment_list", $comment_list );        $this->assign( "nav_curr", "shijiu" );        $this->_config_seo( );        $this->display( );    }    public function shortcut( )    {        $Shortcut = "[InternetShortcut] \r\n\t\tURL=".." \r\n\t\tIDList= \r\n\t\t[{000214A0-0000-0000-C000-000000000046}] \r\n\t\tProp3=19,2 \r\n\t\t";        header( "Content-type: application/octet-stream" );        header( "Content-Disposition: attachment; filename=".c( "ftx_site_name" ).".url;" );        echo $Shortcut;    }    public function cate( )    {        $cid = $this->_get( "cid", "trim" );        $sort = $this->_get( "sort", "trim", "hot" );        $status = $this->_get( "status", "trim", "all" );        $order = "ordid asc ";        switch ( $sort )        {        case "new" :            $order .= ", coupon_start_time DESC";            break;        case "price" :            $order .= ", price DESC";        }        switch ( $status )        {        case "all" :            $map['status'] = "underway";            break;        case "underway" :            $map['status'] = "underway";            break;        case "sellout" :            $map['status'] = "sellout";        }        $id_arr = $this->_cate_mod->get_child_ids( $cid, TRUE );        $map['cate_id'] = array(            "IN",            $id_arr        );        $spid = $this->_cate_mod->where( array(            "id" => $cate_id        ) )->getField( "spid" );        if ( $spid == 0 )        {            $spid = $cid;        }        else        {            $spid .= $cid;        }        $this->assign( "cid", $cid );        $map['pass'] = "1";        $index_info['sort'] = $sort;        $index_info['status'] = $status;        $index_info['cid'] = $cid;        $page_size = c( "ftx_index_page_size" );        $p = $this->_get( "p", "intval", 1 );        $index_info['p'] = $p;        $start = $page_size * ( $p - 1 );        $item_mod = m( "items" );        $items_list = $item_mod->where( $map )->order( $order )->limit( $start.",".$page_size )->select( );        $items = array( );        foreach ( $items_list as $key => $val )        {            $items[$key] = $val;            $items[$key]['class'] = $this->_mod->status( $val['status'], $val['coupon_start_time'], $val['coupon_end_time'] );        }        f( "items_list", $items );        $this->assign( "items_list", $items );        $this->assign( "index_info", $index_info );        $count = $item_mod->where( $map )->count( );        $pager = $this->_pager( $count, $page_size );        $this->assign( "page", $pager->fshow( ) );        $this->assign( "total_item", $count );        if ( FALSE === ( $cate_list = f( "cate_list" ) ) )        {            $cate_list = d( "items_cate" )->cate_cache( );        }        $this->assign( "cate_list", $cate_list );        $item_comment_mod = m( "items_comment" );        $comm_map['status'] = "1";        $comment_list = $item_comment_mod->where( $comm_map )->order( "add_time DESC" )->limit( "0,10" )->select( );        $this->assign( "comment_list", $comment_list );        $this->assign( "nav_curr", "shijiu" );        $cate = d( "items_cate" )->where( array(            "id" => $cid        ) )->find( );        $this->_config_seo( c( "ftx_seo_config.cate" ), array(            "cate_name" => $cate['name'],            "seo_title" => $cate['seo_title'],            "seo_keywords" => $cate['seo_keys'],            "seo_description" => $cate['seo_desc']        ) );        $this->display( );    }}?>


Reply to discussion (solution)

$ Item_mod = m ("items"); add $ map ['Cate _ id'] = 11;
I don't know if the landlord wants this result. I hope it will help you.

Or you can do the same on the template page,
Add the following to the items_list loop: // The data you want to output

Or you can do the same on the template page,
Add the following to the items_list loop: // The data you want to output I want to output the data of cate_id = 11.

Reference the reply from nowphp on the second floor: Or you can do the same on the template page,
Add the following to the items_list loop: // The data you want to output I just want to output the data for cate_id = 11. well, the upstairs method is fine.

Reference the reply from zhouang1989 on the third floor: reference the reply from nowphp on the second floor: Or you can do the same on the template page,
Add the following to the items_list loop: // The data you want to output I just want to output the data for cate_id = 11. well, the upstairs method is fine.
Okay, thank you. I'll try it.

Or you can do the same on the template page,
Add the following to the items_list loop: // The data you want to output

How should I express the value of cate_id not equal to 11?

Reference the reply from nowphp on the second floor: Or you can do the same on the template page,
Add the following to the items_list loop: // The data you want to output

How should I express the value of cate_id not equal to 11?
// The data you want to output

Reference the reply from zhouang1989 on the 6th Floor: reference the reply from nowphp on the 2nd floor: Or you can do the same on the template page,
Add the following to the items_list loop: // The data you want to output

How should I express the value of cate_id not equal to 11?
......
Read the development documentation found Thank you http://www.thinkphp1.cn/info/115.html

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.