我想根据博客显示相关评论

时间:2016-11-09 10:59:04

标签: php html codeigniter

我正在使用codeignitor。我想根据博客显示相关评论。相关评论仅显示一个博客而非其他博客! 这是我的代码:

<section>
  <div class="col-md-9 blog-contrainer">
    <?php if(!empty($blog_data) && isset($blog_data)){ foreach($blog_data as $blog_data) { ?>
    <div class="row blog">
      <div class="col-md-4">
        <img src="<?php echo base_url();?>assets/img/blog.png" class="img-thumbnail img-responsive">
      </div>

      <div class="col-md-8 blog-detail">
        <div class="row">
          <div class="blog-title">
            <h3> <?php echo $blog_data['blog_id']; ?> <?php echo $blog_data['blog_title']; ?></h3>
            <p>Written by
              <?php echo $blog_data[ 'firstname']; ?>
            </p>
          </div>
          <div class="social-follwers">
            <div class="following col-md-3">
              <a href="#"><i class="fa fa-thumbs-up" area-hidden="true"></i> Following<span class="badge">25</span></a>
            </div>
            <div class="Comments col-md-3">
              <a href="#"><i class="fa fa-comment" area-hidden="true"></i>Comments<span class="badge">25</span> </a>
            </div>
          </div>
          <div class="col-md-12">
            <p>
              <?php echo $blog_data[ 'blog_txt']; ?>
            </p>

          </div>


          <div class="col-md-12 comment-box">

            <?php //var_dump($query);die; if(isset($list) && !empty($list)) { foreach($list as $list) { if($list[ 'blog_id_frk']==$blog_data[ 'blog_id']){ ?>
            <div class="blockquote col-md-12 col-xs-12">

              <div class="imag-box col-md-2 col-xs-4">
                <img src="<?php echo base_url();?>upload/user/<?php if(isset($list['propic'])&& !empty($list['propic'])){ echo $list['propic']; } ?>" class="img-thumbnail img-responsive">
              </div>
              <div class="comment-box-detail col-md-10 col-xs-8">
                <p>
                  <?php if(isset($list[ 'comment'])&& !empty($list[ 'comment'])){ echo $list[ 'comment']; } ?>
                </p>
              </div>
            </div>
            <?php } } } ?>

            <div class="col-md-12 col-xs-12">
              <div class="imag-box col-md-2 col-xs-4">
                <img src="images/profile.jpg" class="img-thumbnail img-responsive">
              </div>
              <div class="comment-box-area col-md-10 col-xs-8">

                <form id="frmComment" name="frmComment" method="post" action="<?php echo base_url();?>index.php/registration/add_comment">
                  <input type="hidden" id="blog_id" name="blog_id" value="<?php echo $blog_data['blog_id'];?>">

                  <?php $register_id=$this->session->userdata('registration_id'); if(!empty($register_id)){?>
                  <input type="text" onkeypress="Javascript: if (event.keyCode==13) return add_comment();" placeholder="Write a comment" name="comment" id="comment_<?php echo $blog_data['blog_id'];?>" class="form-control">
                </form>
                <?php } else {?>
                <input type="text" onkeypress="alert('Please sign in')" placeholder="Write a comment" name="comment" id="comment" class="form-control">
                <?php } ?>

              </div>
            </div>
          </div>

        </div>
      </div>

    </div>

    <?php } } ?>
  </div>

</section>

有人可以帮帮我吗?

0 个答案:

没有答案