本文实例分析了thinkPHP商城公告功能开发问题。分享给大家供大家参考,具体如下:
效果如下
1.定在头部
位置:固定;z指数: 999;top : 0;opa city 336012 . Ajax处理json数据
//获取商城公告函数getNotice() { //获取公告函数var res$。ajax({ type: 'POST '、URL : ' { sh :3360 u(' Store/Mall/Ajax get notice '),数组(' mid'=$mid))} '、dataType:'json '、//设为json之后,就能够很好的处理获取的json数据,json.status async: false,success:函数(JSON){ RES=JSON;} });返回res}设置数据类型:“JSON”之后,json数据就直接可以通过json .的方式处理了。
3.最后加载,页面更好看。
$(文档)。就绪(功能(e) { //主函数//获取公告var action _ NAME=' { sh : action _ NAME } ';//页面使用thinkphp常量var JSON=GetNotification();if(action _ name==' index ' JSON。status==1){//首页并且公告存在$('.顶部').css(“”页边距-顶部,' 70px ');//jquery设置css $(' .主边栏')。css('top ',' 70px ');var html=$。每个(json.info,function(i,n){ //n为文本内容html=' listrong ' n . content/strong/Li ' });$('.顶端-注意')。show();$(' #注意ul ').html(“‘html’);$('#notice ').unslider();//轮播}});4.获取结构化查询语言语句的thinkphp处理
//获取公告函数AJaxGetNotice(){ if(IS _ AJAX){ $ this-mid;//获取有效的,且结束时间大于当前时间的,或者日期等于0的公告$ mallnicemodel=M(' Mall _ notice ');$其中[' mall _ id ']=$ this-mid;$其中[' status ']=1;$其中['endtime']=array(array('eq ',0),array('gt ',time()),' or ');//从sh _ mall _ note中选择*其中mall_id=9,status=1和(endtime=0或结束时间1458354366);$ notice=$ mallnicemodel-where($ where)-order(' sort desc ')-select();if(!empty($ note)){ $ this-AJaxreturn(数组(' status'='1 ',' info'=$notice,' msg'='获取成功),' JSON ');} else { $this-ajaxReturn(数组(' status'='2 ',' info '=$ notice,' msg'='公告不存在),' JSON ');} } } $其中['endtime']=array(array('eq ',0),array('gt ',time()),' or ');巧妙的处理了这种逻辑关系。
更多关于thinkPHP相关内容感兴趣的读者可查看本站专题: 《ThinkPHP入门教程》 、 《thinkPHP模板操作技巧总结》 、 《ThinkPHP常用方法总结》 、 《codeigniter入门教程》 、 《CI(CodeIgniter)框架进阶教程》 、 《Zend FrameWork框架入门教程》 、 《smarty模板入门基础教程》 及《PHP模板技术总结》 。
希望本文所述对大家基于ThinkPHP框架的服务器端编程语言(专业超文本预处理器的缩写)程序设计有所帮助。