大侠求助!表items有一字段cate_id,我只想输出cate_id=11的数据,具体应该怎么做呢?在网上查阅了好多资料,Thinkphp的开发文档也看了,没有这方面的介绍,求助了
个人感觉主要是$item_mod = m( "items" );这段决定输出数据,但怎么只输出cate_id=11时的数据还请大虾帮助!
<?phpclass shijiuAction extends frontendAction{ public function _initialize( ) { parent::_initialize( ); $this->_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=".__ROOT__." \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( ); }}?>
回复讨论(解决方案)
$item_mod = m( "items" );前面加入$map['cate_id'] = 11;就可以了
不知道楼主要的是不是这个结果,希望对你有帮助。
或者你要在模板页面也可以这样,
在循环items_list的里面加入:
或者你要在模板页面也可以这样,
在循环items_list的里面加入:
引用 2 楼 nowphp 的回复:或者你要在模板页面也可以这样,
在循环items_list的里面加入:
引用 3 楼 zhouang1989 的回复:引用 2 楼 nowphp 的回复:或者你要在模板页面也可以这样,
在循环items_list的里面加入:
好的谢谢啦哈 我试试去 好人一生平安
或者你要在模板页面也可以这样,
在循环items_list的里面加入:
如果要输出cate_id 不等于 11的值应该怎么表达啊
引用 2 楼 nowphp 的回复:或者你要在模板页面也可以这样,
在循环items_list的里面加入:
如果要输出cate_id 不等于 11的值应该怎么表达啊
引用 6 楼 zhouang1989 的回复:引用 2 楼 nowphp 的回复:或者你要在模板页面也可以这样,
在循环items_list的里面加入:
如果要输出cate_id 不等于 11的值应该怎么表达啊
看了下开发文档找到了 谢谢啦 http://www.thinkphp.cn/info/115.html

長URL(通常用關鍵字和跟踪參數都混亂)可以阻止訪問者。 URL縮短腳本提供了解決方案,創建了簡潔的鏈接,非常適合社交媒體和其他平台。 這些腳本對於單個網站很有價值

在Facebook在2012年通過Facebook備受矚目的收購之後,Instagram採用了兩套API供第三方使用。這些是Instagram Graph API和Instagram Basic Display API。作為開發人員建立一個需要信息的應用程序

Laravel使用其直觀的閃存方法簡化了處理臨時會話數據。這非常適合在您的應用程序中顯示簡短的消息,警報或通知。 默認情況下,數據僅針對後續請求: $請求 -

這是有關用Laravel後端構建React應用程序的系列的第二個也是最後一部分。在該系列的第一部分中,我們使用Laravel為基本的產品上市應用程序創建了一個RESTFUL API。在本教程中,我們將成為開發人員

Laravel 提供简洁的 HTTP 响应模拟语法,简化了 HTTP 交互测试。这种方法显著减少了代码冗余,同时使您的测试模拟更直观。 基本实现提供了多种响应类型快捷方式: use Illuminate\Support\Facades\Http; Http::fake([ 'google.com' => 'Hello World', 'github.com' => ['foo' => 'bar'], 'forge.laravel.com' =>

PHP客戶端URL(curl)擴展是開發人員的強大工具,可以與遠程服務器和REST API無縫交互。通過利用Libcurl(備受尊敬的多協議文件傳輸庫),PHP curl促進了有效的執行

您是否想為客戶最緊迫的問題提供實時的即時解決方案? 實時聊天使您可以與客戶進行實時對話,並立即解決他們的問題。它允許您為您的自定義提供更快的服務

2025年的PHP景觀調查調查了當前的PHP發展趨勢。 它探討了框架用法,部署方法和挑戰,旨在為開發人員和企業提供見解。 該調查預計現代PHP Versio的增長


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

MantisBT
Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

DVWA
Damn Vulnerable Web App (DVWA) 是一個PHP/MySQL的Web應用程序,非常容易受到攻擊。它的主要目標是成為安全專業人員在合法環境中測試自己的技能和工具的輔助工具,幫助Web開發人員更好地理解保護網路應用程式的過程,並幫助教師/學生在課堂環境中教授/學習Web應用程式安全性。 DVWA的目標是透過簡單直接的介面練習一些最常見的Web漏洞,難度各不相同。請注意,該軟體中

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

Dreamweaver Mac版
視覺化網頁開發工具