dongqiang1894 2015-07-08 09:01
浏览 45
已采纳

提交的表单bootstrap / php列表

I am trying to get a list of users submitted forms, each with image, title, description and an edit and delete button. I was trying to get them in a list without numbers or bullets, one after another, but I am not succeding, any help would be very much appreciated. Thank you in advance. Here is the code:

<div class="container-fluid">
<p><a href="/validated/shows/create-show" class="btn btn-primary" role="button">Create show</a></p>
        @if(sizeof($shows) > 0)
    @foreach($shows as $index => $show)
    @if($index%3 == 0)
        <div class="row">
        @endif
          <div class="col-sm-6 col-md-3">
            <div class="thumbnail">
                <img src="{{$show->path}}">
              <div class="caption">
                <h3>{{$show->title}}</h3>
                <p>{{$show->description}}</p>
              </div>
              <p><a href="/validated/shows/edit-show/{{$show->id}}" class="btn btn-primary" role="button">Edit Show</a></p>
              <form action="/validated/shows/delete-show" method="POST">
                <input type="hidden" name="_token" value="{{ csrf_token() }}" required>
                <input type="hidden" name="id" value="{{$show->id}}" required>
            <p><a href="/validated/shows/delete-show/{{$show->id}}" class="btn btn-primary" role="button">Delete</a></p>
            </form>
            </div>
          </div>
        @if(($index+1)%3 == 0)
        </div>
        @endif
    @endforeach

</div>
  • 写回答

1条回答 默认 最新

  • doutuo4285 2015-07-08 10:50
    关注

    It looks like you using some php template engine in your example, so here is my solution on pure php without any template engines. This snippet will output shows by three per row.

    <?php if(count($shows) > 0): ?>
        <div class="row">
    
        <?php foreach($shows as $index => $show): ?>
    
            <div class="col-sm-6 col-md-3">
                <div class="thumbnail">
                    <img src="<?= $show->path ?>">
                    <div class="caption">
                        <h3><?= $show->title ?></h3>
                        <p><?= $show->description ?></p>
                    </div>
                    <p>
                        <a href="/validated/shows/edit-show/<?= $show->id ?>" class="btn btn-primary" role="button">Edit Show</a>
                    </p>
                    <form action="/validated/shows/delete-show" method="POST">
                        <input type="hidden" name="_token" value="<?=  csrf_token() ?>" required>
                        <input type="hidden" name="id" value="<?= $show->id ?>" required>
                        <p><a href="/validated/shows/delete-show/<?= $show->id ?>" class="btn btn-primary" role="button">Delete</a></p>
                    </form>
                </div>
            </div>
            <?php if(
                (($index + 1) % 3) == 0 && $index < (count($shows) - 1)): ?>
                </div>
                <div class="row">
            <?php endif; ?>
        <?php endforeach; ?>
        </div>
    <?php endif; ?>
    

    But if you want really responsove layout, just exclude this part from the code (as for as you using bootstrap, it will do all work for you - see fiddle):

    <?php if((($index + 1) % 3) == 0 && $index < (count($shows) - 1)): ?>
        </div>
        <div class="row">
    <?php endif; ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码