href:'__URL__/sblog/id/'+idd,
//$json為NULL輸出模板。為1時輸出資料行表資料到前端,格式為Jsonpublic function sblog($json=NULL,$id=NULL){if(!is_int((int)$json)){$json = NULL;} //dump($id); 這裡能顯示ID為16if($json==1){$sblog = M('Sbly_table');//$id = intval($id);//$info = $sblog->order('id desc')->where('lj_sbid='.$id)->select();$info = $sblog->order('id desc')->select();$new_info = array();foreach($info as $t){if($t['lj_ly_zt']==1){$t['lj_ly_zt'] = '開啟';}else{$t['lj_ly_zt'] = '關閉';}$new_info[] = $t;}echo json_encode($new_info);unset($sblog,$info,$new_info);}else{$this->display();}unset($Public); }
$json=1時, 輸出如下3條內容:
[{"id":"38","user_id":"1","title":"001","lj_sbid":"16"},{"id":"36","user_id":"1","title":"002","lj_sbid":"18"},
{"id":"34","user_id":"1","title":"003","lj_sbid":"17"}]
前端處理後能正確顯示3行資料,但是我只想要顯示lj_sbid為16的資料,
$info = $sblog->order('id desc')->where('lj_sbid=16')->select();
這樣能正確顯示lj_sbid為16的一條資料,但是這樣:
$info = $sblog->order('id desc')->where('lj_sbid='.$id)->select();
又不能輸出?該怎麼寫才對?先謝謝大家了
回複討論(解決方案)
理論上寫的沒什麼問題,你可以嘗試輸出下$id是什麼值
order應該在where 後邊
$id能輸出16,到底是哪裡錯誤呢?
你要的不是$id的值
模板sql語句 文法有問題
你要的不是$id的值
模板sql語句 文法有問題
$id只是條件,語法錯誤在哪裡?請高手指點一下,謝謝主!
dump($id); 貼出結果
dump($id);
輸出:
string(2) "16"
你不是用 EasyUI 嗎?
string(2) "16" 在哪裡看到的?
TinkPHP+EasyUI
sblog.htm模板輸出的
用 Volist標籤老顯示載入中......,改用Foreach標籤就OK了