时间:2021-07-01 10:21:17 帮助过:10人阅读
$sql_block = "select * from " . C('db_prefix') . "small_block order by ssort desc,bid desc,szone desc"; $query_block = mysql_query($sql_block); $data_block = array(); $data_big = array(); $time1 = date("Y-m-d"); $time1 .= " 00:00:00"; $time2 = date("Y-m-d"); $time2 .= " 23:59:59"; while ($arr_block = mysql_fetch_array($query_block)) { $data_block[] = $arr_block; $bsql = "select * from " . C('db_prefix') . "big_block where id=" . $arr_block['bid']; $barr = mysql_fetch_array(mysql_query($bsql)); $data_big[$arr_block['bid']] = $barr['bzone']; ${'zhuti' . $arr_block['id']} = mysql_num_rows(mysql_query("select * from " . C('db_prefix') . "talk where parentid=" . $arr_block['id'])); $this->assign("zhuti" . $arr_block['id'], ${'zhuti' . $arr_block['id']}); ${'tiezi1' . $arr_block['id']} = mysql_num_rows(mysql_query("select * from " . C('db_prefix') . "talk where parentid=" . $arr_block['id'])); ${'tiezi2' . $arr_block['id']} = mysql_num_rows(mysql_query("select * from " . C('db_prefix') . "reply where parentid2=" . $arr_block['id'])); ${'tiezi' . $arr_block['id']} = ${'tiezi1' . $arr_block['id']} + ${'tiezi2' . $arr_block['id']}; $this->assign("tiezi" . $arr_block['id'], ${'tiezi' . $arr_block['id']}); ${'arc' . $arr_block['id']} = $this->find(C('db_prefix') . "talk", "string", "parentid=" . $arr_block['id'] . " order by timeup desc"); $this->assign("arc" . $arr_block['id'], ${'arc' . $arr_block['id']}); ${'today1' . $arr_block['id']} = $this->select("select count(*) as count1 from " . C('db_prefix') . "talk where parentid in " . "(".$arr_block['id'].",".(int)($arr_block['id']+10000).")". " and time1 between '" . $time1 . "' and '" . $time2 . "'"); ${'today2' . $arr_block['id']} = $this->select("select count(*) as count2 from " . C('db_prefix') . "reply where parentid2 in" . "(".$arr_block['id'].",".(int)($arr_block['id']+10000).")". " and time2 between '" . $time1 . "' and '" . $time2 . "'"); ${'today' . $arr_block['id']} = ${'today1' . $arr_block['id']}[0][count1] + ${'today2' . $arr_block['id']}[0][count2]; $this->assign("today" . $arr_block['id'], ${'today' . $arr_block['id']}); }
$sql_block = "select * from " . C('db_prefix') . "small_block order by ssort desc,bid desc,szone desc";$query_block = mysql_query($sql_block);$data_block = array();$data_big = array();while ($arr_block = mysql_fetch_array($query_block)) { $data_block[] = $arr_block; $bsql = "select * from " . C('db_prefix') . "big_block where id=" . $arr_block['bid']; $barr = mysql_fetch_array(mysql_query($bsql)); $data_big[$arr_block['bid']] = $barr['bzone']; }
$this->assign('data_big', $data_big) ->assign('data_block', $data_block);
array_array['data_big'])){ foreach($this->array_array['data_big'] as $k => $n){ ?> //此处可以以自定义丰富的样式输出$k(大版块ID)或$n(大版块名称) array_two['data_block'])){ foreach($this->array_two['data_block'] as $v){ if($v['bid']!=$k) continue;?> //此处可以以自定义丰富的样式输出遍历的$v,小版块名称为$v['szone']
好东西
谢谢分享,很好的教程
"可以以小版块影响大版块的排序"这个是什么意思?
"可以以小版块影响大版块的排序"这个是什么意思?
意思就是
比如
大版块国家 小版块 中国(排序ID=10) 美国(排序ID=20)
大版块城市 小版块 北京(排序ID=10) 上海(排序ID=21)
你们觉得怎么排序?
1、上海ID最大,因此大版块排序以城市排列在最上面
2、上海比北京大,小版块之间,以上海排在最上面
设计库设计分为2张表
……
为什么不直接用一张表,用一个fid标示是否有子版块及子版块id
引用 楼主 xjl756425616 的回复:设计库设计分为2张表
……
为什么不直接用一张表,用一个fid标示是否有子版块及子版块id
我没尝试过~因为还有涉及到后台的版块管理,表分开会容易点操作
引用 5 楼 nowphp 的回复:引用 楼主 xjl756425616 的回复:设计库设计分为2张表
……
为什么不直接用一张表,用一个fid标示是否有子版块及子版块id
我没尝试过~因为还有涉及到后台的版块管理,表分开会容易点操作
呵呵,我也只是发表一下我的意见,仅供参考。如果你的小版块要有子版块的话,估计就需要一个表好一点。因为不可能在去新建一个表了是吧。
如;category表:id,fid,name,leftid(上一个版块),rightid(下一个版块),banzhu