doujia4041 2018-10-26 06:47
浏览 15

foreach循环检索并显示最后的星级评级的价值

I have this div where ratings are shown and the ratings are fetched from db and values are getting outputted But my Problem only the last star rating value of the userid is shown

View Page

<?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  }    ?>

Controller:

 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();
    }

Model:

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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 测距传感器数据手册i2c
    • ¥15 RPA正常跑,cmd输入cookies跑不出来
    • ¥15 求帮我调试一下freefem代码
    • ¥15 matlab代码解决,怎么运行
    • ¥15 R语言Rstudio突然无法启动
    • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
    • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法