Help.., cara membuat looping

<div class="container" data-aos="fade-up">

        <div class="section-title">
          <h2>Portfolio</h2>
          <p>Check out our beautifull portfolio</p>
        </div>

        <div class="row" data-aos="fade-up" data-aos-delay="100">
          <div class="col-lg-12">
            <ul id="portfolio-flters">
              <li data-filter="*" class="filter-active">All</li>
              <li data-filter=".filter-app">App</li>
              <li data-filter=".filter-card">Card</li>
              <li data-filter=".filter-web">Web</li>
            </ul>
          </div>
        </div>

        <div class="row portfolio-container" data-aos="fade-up" data-aos-delay="200">

          <!-- <div class="col-lg-4 col-md-6 portfolio-item filter-app">

            <div class="portfolio-wrap">

              <img src="assets/img/portfolio/portfolio-1.jpg" class="img-fluid" alt="">
              <div class="portfolio-links">
                <a href="assets/img/portfolio/portfolio-1.jpg" data-gallery="portfolioGallery" class="portfolio-lightbox" title="App 1"><i class="bi bi-plus"></i></a>
                <a href="portfolio-details.html" title="More Details"><i class="bi bi-link"></i></a>
              </div>
              <div class="portfolio-info">
                <h4>App 1</h4>
                <p>App</p>
              </div>
            </div>
          </div>
<div class="col-lg-4 col-md-6 portfolio-item filter-card">
            <div class="portfolio-wrap">
              <img src="assets/img/portfolio/portfolio-8.jpg" class="img-fluid" alt="">
              <div class="portfolio-links">
                <a href="assets/img/portfolio/portfolio-8.jpg" data-gallery="portfolioGallery" class="portfolio-lightbox" title="Card 3"><i class="bi bi-plus"></i></a>
                <a href="portfolio-details.html" title="More Details"><i class="bi bi-link"></i></a>
              </div>
              <div class="portfolio-info">
                <h4>Card 3</h4>
                <p>Card</p>
              </div>
            </div>
          </div>

          <div class="col-lg-4 col-md-6 portfolio-item filter-web">
            <div class="portfolio-wrap">
              <img src="assets/img/portfolio/portfolio-9.jpg" class="img-fluid" alt="">
              <div class="portfolio-links">
                <a href="assets/img/portfolio/portfolio-9.jpg" data-gallery="portfolioGallery" class="portfolio-lightbox" title="Web 3"><i class="bi bi-plus"></i></a>
                <a href="portfolio-details.html" title="More Details"><i class="bi bi-link"></i></a>
              </div>
              <div class="portfolio-info">
                <h4>Web 3</h4>
                <p>Web</p>
              </div>
            </div>
          </div>

        </div>

      </div>
avatar argachristian
@argachristian

11 Kontribusi 1 Poin

Diperbarui 1 tahun yang lalu

Tanggapan

Pertanyaan kamu tidak jelas, coba dijelaskan lebih baik

membuat looping pada gambar yang ada di dalam div pak

1 Jawaban:

<div>masalahnya disini, kamu tidak memberitahu array yang ingin di looping,, jadi kami tidak tahu musti apa yang di looping, dan harus menggunakan apa,, (while, for, atau yang lainnya)<br>misal aja kita punya array data portfolio,, maka, mungkin bisa dibuat seperti ini</div><pre>&lt;?php // Data portfolio dalam bentuk array $portfolio = array( array( 'filter' =&gt; 'filter-app', 'image' =&gt; 'assets/img/portfolio/portfolio-1.jpg', 'title' =&gt; 'App 1', 'category' =&gt; 'App' ), array( 'filter' =&gt; 'filter-card', 'image' =&gt; 'assets/img/portfolio/portfolio-8.jpg', 'title' =&gt; 'Card 3', 'category' =&gt; 'Card' ), array( 'filter' =&gt; 'filter-web', 'image' =&gt; 'assets/img/portfolio/portfolio-9.jpg', 'title' =&gt; 'Web 3', 'category' =&gt; 'Web' ) );

// Looping portfolio foreach ($portfolio as $item) { echo '&lt;div class="col-lg-4 col-md-6 portfolio-item ' . $item['filter'] . '"&gt;'; echo '&lt;div class="portfolio-wrap"&gt;'; echo '&lt;img src="' . $item['image'] . '" class="img-fluid" alt=""&gt;'; echo '&lt;div class="portfolio-links"&gt;'; echo '&lt;a href="' . $item['image'] . '" data-gallery="portfolioGallery" class="portfolio-lightbox" title="' . $item['title'] . '"&gt;&lt;i class="bi bi-plus"&gt;&lt;/i&gt;&lt;/a&gt;'; echo '&lt;a href="portfolio-details.html" title="More Details"&gt;&lt;i class="bi bi-link"&gt;&lt;/i&gt;&lt;/a&gt;'; echo '&lt;/div&gt;'; echo '&lt;div class="portfolio-info"&gt;'; echo '&lt;h4&gt;' . $item['title'] . '&lt;/h4&gt;'; echo '&lt;p&gt;' . $item['category'] . '&lt;/p&gt;'; echo '&lt;/div&gt;'; echo '&lt;/div&gt;'; echo '&lt;/div&gt;'; } ?&gt; <br></pre><div><br><br></div>

avatar yukari06
@yukari06

137 Kontribusi 66 Poin

Dipost 1 tahun yang lalu

Tanggapan

Terima Kasih Pak

Login untuk ikut Jawaban