thinkphp专题提供thinkphp的最新资讯内容,帮你更好的了解thinkphp。
请求获取并展示二维码<img src="<?php echo U('createCode?zsnumber='.$time.$kcname['id'].$stuInfo['id'].'&stuName='.$stuInfo['stu_name'].'&sfid='.$stuInfo['sfid'].'&kcName='.$kcname['classnew'].'&kcid='.$kcid.'&stuid='.$stuInfo['id'].'');?>" alt="二维码" class="code">创建二维码public function createCode(){header('Content-Type: image/png');Vendor('phpqrcode.phpqrcode');ob_clean(); // 这里一开始我没有加 显示正常 后来就一直显示不了了 之后加上就好了 网上也有几种说法,但是我认为是缓冲区的问题$value = 'http://XXXXXX/Home/mystudy/showcode?zsnumber='.$_GET['zsnumber'].'&stuName='.$_GET['stuName'].'&sfid='.$_GET['sfid'].'&kcName='.$_GET['kcName'].'&kcid='.$_GET['kcid'].'&stuid='.$_GET['stuid'].''; QRcode::png($value,false, 'H', 8, 2, false); }二维码链接信息处理public function showcode(){dump($_GET); 获得二维码中信息$temp['kcid'] =$_GET['kcid'];$temp['userid'] = $_GET['stuid'];$info = D('表名')->where($temp)->find();$this->assign('info',$info);$this->display();}
thinkphp配置文件路径在入口文件index.php中配置。如果Public目录在应用程序目录同等级位置:2.如果Public在app内部则:3.如果使用Public在app外部,但定义为:define('APP_PATH','./Application/');
<?phpreturn array(//'配置项'=>'配置值''MODULE_ALLOW_LIST' => array('Home'),'DEFAULT_MODULE' => 'Home', // 默认模块'APP_URL' => 'http://app.weilan.com','VIP_URL' => 'http://vip.weilan.com','Wap_URL' => 'http://Wap.weilan.com',//'VIP_INTER'=>'http://vip.anyicaifu.com:8080/App/AppRequests/index','VIP_INTER'=>'192.168.1.102/App/AppRequests/index',//'VIP_INTER'=>'vip.weilan.com/App/AppRequests/index',TMPL_PARSE_STRING=>array('APP_PATH'=>'WapSources'),);
thinkphp文件夹下config 里面有个convention.php文件 里面有三个配置'DEFAULT_MODULE' => 'Home', // 默认模块'DEFAULT_CONTROLLER' => 'Index', // 默认控制器名称'DEFAULT_ACTION' => 'index', // 默认操作名称改掉这三个就可以改默认的首页
I() 方法用于获取前台提交的表单的value值。<form id="complai_form" method="post" action="{:U('Index/Complai')}"><div class="com_area"><div style="width:80%;height:50px;margin:0 auto;"><div class="ser_mbx">我要投诉</div></div><textarea rows="10" cols="80" class="com_text" name="yang" maxlength="500" style="width:80%;"></textarea><div style="width:90%;height:20px;text-align:right;"><span style="font-size:12px;color:gray;">内容字数小于500字</span></div><div class="com_tbox"><input type="submit" id="subn" value="提交" /></div></div></form>后台I方法获取:$content = I('param.yang'); //param.yang yang等于name="yang" input或者是taxtarea的name名称 不是idvar_dump($content);
1.从该处进入导航页面,点击分贝进入点击的页面。2.点击1处进入对应的导航栏,导航栏变色。3.在1图图片点击跳转是给地址添加参数status。4.在后台IndexController.class.php处接收status的值并赋值给前台。5.前台用hidden值接收status的值6.写jquery,关联状态值7. active的值先写好css属性.ser_box{width:100%;height:100%;overflow-y:auto}.ser_header{width:100%;height:90px;}.ser_headc{width:85%;height:90px;border-bottom:1px solid #C4DBED;margin:0 auto;}.ser_left{width:20%;height:90px;float:left;}.ser_center{width:60%;height:90px;float:left;}.ser_right{width:19%;height:90px;float:left;text-align:right;font-size:12px;}.ser_text{vertical-align:middle;margin-left:45px;}.ser_ul{list-style:none;overflow:hidden;margin:0 auto;width:100%;}.ser_ul li{float:left;height:40px;line-height:40px;border:1px solid #C4DBED;border-bottom:none;}.ser_li{width:12%;}.ser_li_speical{width:14%;}.img1{background:url(../images/dowers.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#636162;}.img1.active{background:url(../images/dowers_w.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#FFF;background-color:#557FB9;}.img1:hover{background:url(../images/dowers_w.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#FFF;background-color:#557FB9;}.img2{background:url(../images/housekeep.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#636162;}.img2.active{background:url(../images/housekeep_w.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#FFF;background-color:#557FB9;}.img2:hover{background:url(../images/housekeep_w.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#FFF;background-color:#557FB9;}.img3{background:url(../images/mall.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#636162;}.img3.active{background:url(../images/mall_w.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#FFF;background-color:#557FB9;}.img3:hover{background:url(../images/mall_w.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#FFF;background-color:#557FB9;}.img4{background:url(../images/checkin.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#636162;}.img4.active{background:url(../images/checkin_w.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#FFF;background-color:#557FB9;}.img4:hover{background:url(../images/checkin_w.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#FFF;background-color:#557FB9;}.img5{background:url(../images/payment.png)no-repeat;background-size: 22px 22px;background-position:10px;color:#636162;}.img5.active{background:url(../images/payment_w.png)no-repeat;background-size: 22px 22px;background-position:10px;color:#FFF;background-color:#557FB9;}.img5:hover{background:url(../images/payment_w.png)no-repeat;background-size: 22px 22px;background-position:10px;color:#FFF;background-color:#557FB9;}.img6{background:url(../images/tool.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#636162;}.img6.active{background:url(../images/tool_w.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#FFF;background-color:#557FB9;}.img6:hover{background:url(../images/tool_w.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#FFF;background-color:#557FB9;}.img7{background:url(../images/complaints.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#636162;}.img7.active{background:url(../images/complaints_w.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#fff;background-color:#557FB9;}.img7:hover{background:url(../images/complaints_w.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#fff;background-color:#557FB9;}.img8{background:url(../images/car.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#636162;}.img8.active{background:url(../images/car_w.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#fff;background-color:#557FB9;}.img8:hover{background:url(../images/car_w.png)no-repeat;background-size: 22px 22px;background-position:20px;color:#fff;background-color:#557FB9;}
1. 先去数据库中查值,查询整个数据表,结果为二维数组。$project = M("project");$cell = $project->where(array('status'=>1))->order("id desc")->select();//var_dump($cell);$this->assign('cell',$cell);2.前台获取遍历<select class="test" style="width:88%;height:35px;border-style:none;color:#767676;" id="projectno" name="projectno"><option>&nbsp请输入您的所在小区</option><volist name="cell" id="vo"><option value="{$vo['id']}">{$vo['name']}</option></volist></select>
1.在thinkphp控制器类使用命名空间2.把Page.class.php放入到该目录3.public function Repair(){$status=I('param.status','6');$this->assign('status',$status);$cuername=session('user.name');$repair = M('repairinfo'); //实例化数据表$count=$repair->where(array('cuername' =>$cuername))->count(); //查询总数/*实例化分页类 传入总记录数和每页显示的记录数*/$Page = new Page($count,10);///*分页显示输出*/$show = $Page->show();/*进行分页数据查询 注意limit方法的参数要使用Page类的属性*/$page=I('param.p'); //接收前台参数p位置if(empty($page)){$page=1;}$list=$repair->where(array('cuername' =>$cuername))->order('applytime desc')->limit($Page->firstRow.",".$Page->listRows)->select(); //分页$this->assign('list',$list); //输出结果$this->assign('page',$show); //输出分页$mobile = parent::isMobile();if($mobile=="true"){$this->display(Wap_Repair);}else{$this->display(Repair);}}4.前台接收{$page}5.css样式.manu{padding:3px;margin:3px;text-align:center;}.manu a{border:#ccc 1px solid;padding:3px 10px;margin:2px;color:#999;text-decoration:none;}.manu a:hover{border:#B5C8CF 1px solid;color:#fff;background-color:#B5C8CF;}.manu a:active{border:#999 1px solid;color:#666;}.manu .current{border:#B5C8CF 1px solid;padding:3px 10px;margin:2px;color:#fff;background-color:#B5C8CF;}.manu .disabled{border:#eee 1px solid;padding:2px 5px;margin:2px;color:#ddd;}6.class类已经上传
if($user->where('phone='.$phone)->save($dataList)){}if($user->where(array('phone' =>$phone))->save($dataList)){}thinkphp更新数据库的时候where('')为字符串,要么为数组。为字符串要点连接
var_dump($repair->fetchSql(true)->where(array('cuername' =>$cuername))->order('applytime desc')->limit($page1*$listRows,$listRows)->select());$list=$repair->where(array('cuername'=>$cuername))->order('applytime desc')->limit($page1*$listRows,$listRows)->select();
1.两个表查询$userid=session('user.id');$user = M('cuser');$data = $user->field('projectno')->where(array('id'=>$userid))->select();$xq = M('project');$datas = $xq->field('name')->where(array('id'=>$data[0][projectno]))->select();$this->assign('xq',$datas);$this->assign('title',$datas[0][name].'物业系统');2.联合查询:联合查询需要写表的全名。$userid=session('user.id');$user = M('cuser');$data = $user->join('INNER JOIN pro_project ON pro_cuser.projectno = pro_project.id')->where(array('pro_cuser.id'=>$userid))->select();$this->assign('xq',$data);$this->assign('title',$data[0][name].'物业系统');
<include File="Public:regheader" />
在thinkphp框架下我们经常会用到状态值的判断:但是这样写会引起语法错误。<div><if condition="{$res.status} eq '0'">测试</if></div>2.正确写法:因为在thinkphp在不能使用“.”语法<if condition="$res['status'] eq 0">测试</if>f标签里面已经包含了php的解析了,如果再在里面写入{}标签解析的话,会报不符合php语法的错误。3.<if condition="$res['0']['points'] eq '5'"><div class="ser_mbx btn_center">立即签到</div><else /><div class="already">已签到</div></if>
if(IS_AJAX) {$oldpwd=I('param.oldpwd');}
$res=$user->where("login_id='{$username}' OR phone='{$username}'")->find();$phone=I('param.phone');$sql='select phone,login_id from pro_cuser where phone="'.$data['phone'].'" or login_id="'.$data['phone'].'" and status="1" limit 1';
在thinkphp下通过页面链接传递的参数获取一次后失效,ajax内部无法再次使用。想要使用必须再次用js获取其值,通过ajax传递给后台使用。1.通过页面链接传递参数给下一页2.可以再下一页后台方法获取:3.获取后给前台显示:4.若ajax想要在后台修改密码时再次使用时候需要利用js再次从前台获取其值提交给ajax。可以利用隐藏域获取:5.
老项目tp3.1.3,有N个数据库,thinkphp好久没用了,不知道怎么用M方法了,代码测验成功!数据库名称:2.直接上代码$custom = M('base','branch_','shop'); //base数据表名称;branch_ 数据表前缀;shop 数据库名配置$list = $custom->select();var_dump($list);die;