foreach循环检索并显示LAST STAR RATING的值

时间:2018-10-26 06:47:19

标签: php codeigniter

我有这个div,其中显示了收视率,并从db获取了收视率,并输出了值,但是我的问题仅显示了userid的最后一个星级评分值

查看页面

<?php foreach($testi as $test){ ?>     
    <div class="form-group">
       <fieldset class="rating">
            <legend>Ratings Given:</legend>
            <input type="radio" id="star5" name="hel_banners[rating]" disabled="true" value="5"<?php if($test->rating == 5) echo'checked'; ?> /><label for="star5" title="Rocks!">5 stars</label>
            <input type="radio" id="star4" name="hel_banners[rating]" disabled="true" value="4"<?php if($test->rating == 4) echo'checked'; ?> /><label for="star4" title="Pretty good">4 stars</label>
            <input type="radio" id="star3" name="hel_banners[rating]" disabled="true" value="3"<?php if($test->rating == 3) echo'checked'; ?> /><label for="star3" title="Meh">3 stars</label>
            <input type="radio" id="star2" name="hel_banners[rating]" disabled="true" value="2"<?php if($test->rating == 2) echo'checked'; ?> /><label for="star2" title="Kinda bad">2 stars</label>
            <input type="radio" id="star1" name="hel_banners[rating]" disabled="true" value="1"<?php if($test->rating == 1) echo'checked'; ?> /><label for="star1" title="Sucks big time">1 star</label>
        </fieldset>               
    </div>
<?php  }    ?>

控制器:

 public function index(){
       $data['title'] = "HR & Employee Engagement Testimonials"; 
       $data['descriptions'] = 'Check our website to learn what others say about us.';
       $data['testi'] = $this->Home_model->GettestimonialApprove();
        load_view_frond_template('home/testimonials',$data,$this);
        $this->template->render();
    }

型号:

public function GettestimonialApprove(){
        $where = "categoryid ='7' AND act = '1' ";
        $this->db->select("*")->from('hel_banners')->where($where)->order_by('bId', 'asc');
        $query = $this->db->get();
        return $query->result();
    }

0 个答案:

没有答案