Home > Backend Development > PHP Tutorial > thinkphp,该怎么处理

thinkphp,该怎么处理

WBOY
Release: 2016-06-13 12:59:59
Original
922 people have browsed it

thinkphp

<br />
public function about()<br />
    {<br />
	require(CMS_PATH.'/data/config.php');<br />
	    $id = trim($_REQUEST['id']);<br />
    	$aboutclass = M('aboutclass');<br />
		$list_about=$aboutclass->where('id='.$id)->select();<br />
		$this->assign("aboutclass",$list_about);<br />
		dump($list_about);<br />
    	$this->display();<br />
    }<br />
Copy after login


本人刚开始学习THINKPHP,比如ID=2时这样写只能显示1个分类1条内容。我想ID=2时所有分类显示出来。内容只显示ID=2时对应的表内容。该怎么写?分类和内容是在一张表里的
------解决方案--------------------
要说更好的方法,就是顺蔓摸瓜,找到根源,修正既可,能常记录条数是limit所致
不过这样写也有这样写好处,没有破坏框架结构,别人用一切正常
不用考虑这地方被你修改过了,其实主要原因在那个id上,你改后你要记住这块被改的,
多看看源码,吃透了改啥都好办,祝你更进一步
------解决方案--------------------
<br />
public function about()<br />
    {<br />
    require(CMS_PATH.'/data/config.php');<br />
        $id = trim($_REQUEST['id']);<br />
        $aboutclass = M('aboutclass');<br />
        $list_about['content']=$aboutclass->where('id='.$id)->select();<br />
        $list_about['category']=$aboutclass->select();<br />
        $this->assign("aboutclass",$list_about);<br />
        dump($list_about);<br />
        $this->display();<br />
    }<br />
<br />
Copy after login
 这样怎么样?其实也可以自连接。 不知道lz这样要这样的目的 
加群中国PHP军团(7948162)讨论

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