public function index() { $id = $this->_get('id', 'intval'); $ask = D('AskInfoView')->find($id); if (!$ask) { redirect(U('List/index')); } $ask['level'] = exp_to_level($ask['exp']); $this->ask = $ask; //满意回答 $where = array('aid' => $id, 'answer.adopt' => 1); $this->bingo = D('AnswerInfoView')->where($where)->find(); //全部回答 $where = array('answer.adopt' => 0, 'aid' => $id); import('ORG.Util.Page'); $count = M('answer')->where($where)->count(); $page = new Page($count, 5); $limit = $page->firstRow . ',' . $page->listRows; $answer = D('AnswerInfoView')->where($where)->limit($limit)->select(); // p($answer);die; $this->answer = $answer; $this->page = $page->show(); //待解绝的问题 $where = array('cid' => $ask['cid'], 'solve' => 0, 'id' => array('NEQ', $id)); $wait = M('ask')->where($where)->limit(5)->select(); $this->wait = $wait; $this->display(); }
/** * 我的等级 */ public function myLevel() { //接受用户id $id = $this->_get('id', 'intval'); $this->exp = M('user')->where(array('id' => $id))->getField('exp'); $this->level = exp_to_level($this->exp); $this->display(); }
} ?> <!--背景遮罩--><div id='background' class='hidden'></div> <!--------------------中部--------------------> <div id='center'> <div id='left'> <!--使用userinfo标签--> <?php $field = array('id', 'username', 'face', 'answer', 'adopt', 'ask', 'point', 'exp'); $_userinfoResult = M('user')->field($field)->find($_GET["id"]); extract($_userinfoResult); $face = empty($face) ? '/Public/Images/noface.gif' : '/Uploads/Face/' . $face; $face = __ROOT__ . $face; $adopt = round($adopt / $answer * 100, 1) . '%'; $level = exp_to_level($exp); ?> <div class='userinfo'> <dl> <dt> <a href="<?php echo U('Member/index', array('id' => $id)); ?> "><img src="<?php echo $face; ?> " width='48' height='48'/></a> </dt> <dd class='username'> <a href="<?php echo U('Member/index', array('id' => $id));
?> </span></li> <li>采纳率:<span><?php echo round($starUser['adopt'] / $starUser['answer'] * 100, 1); ?> %</span></li> </ul> </div> <span class='star-name'>历史回答最多的人</span> <!-- 原生php历史回答 --> <?php $todayTime = strtotime(date('y-m-d')); $sql = 'SELECT id,username,face,exp,answer,adopt FROM wd_user ORDER BY answer DESC LIMIT 1'; $answerDay = M()->query($sql); $result = $answerDay[0]; $result['level'] = exp_to_level($result['exp']); ?> <div class='star-info'> <div> <a href="<?php echo U('Member/index', array('id' => $result['id'])); ?> " class='star-face'><img src="<?php if ($result["face"]) { ?> __ROOT__/Uploads/Face/<?php echo $result["face"]; } else { ?> __PUBLIC__/Images/noface.gif<?php }