-1

私はPHPとmySQLを使い始めたばかりで(現在約4日)、この問題の修正を見つけようとしています...

mySQL データベースから返されるアイテムのセットがあります。これらを「モデル」のクラスを持つ4つの「ul」列のセットに流し込み、結果の数を4で割って「li」を返しますが、なぜファントムの空の「ul」があるのか​​ わかりません終わり。「ul」を foreach ステートメントに入れようとしましたが、それも望ましい結果を返しませんでした。

助けてくれてありがとう。

これがphpです:

<grid>
  <ul class="models">
    <?php

    $c = count($model);

    $s = ($c / 4); // change 4 to the number of columns you want to have.

    $i=1;

    foreach ($model as $models): ?>
      <li>
        <a href="model/?id=<?php htmlout($models['sn']); ?>" class="id<?php htmlout($models['sn']); ?>">
          <div class="<?php htmlout($models['callout']); ?>"></div>
          <div id="description">
             <h2><?php htmlout($models['firstname']); ?> <?php htmlout($models['lastname']); ?>
             </h2>
             <h3><span class="number">40</span> photo sets</h3>
             <h3><span class="number">756</span> images</h3>
             <p><?php htmlout($models['rightstext_left']); ?>
                <?php htmlout($models['firstname']); ?>
                <?php htmlout($models['rightstext_right']); ?>
             </p>
          </div>
       </a>
    </li>
    <?php if($i != 0 && $i % $s == 0)
    {
        ?>
  </ul>
  <ul class="models">
    <?php
    }
    $i++; ?>
    <?php endforeach; ?>
  </ul>
</grid>

HTML

<grid>    
**excluded**
<ul class="models">
<li>
   <a href="model/?id=AZWW5RJE" class="idAZWW5RJE">
   <div class="exclusive"></div>
   <div id="description">
      <h2>Model 19</h2>
      <h3><span class="number">1</span> attribute</h3>
      <h3><span class="number">6</span> attributes</h3>
      <p>textleft name textright</p>
    </div>
   </a>
</li>
<li>
   <a href="model/?id=AZWW5RJE" class="idAZWW5RJE">
   <div class="exclusive"></div>
   <div id="description">
      <h2>Model 19</h2>
      <h3><span class="number">1</span> attribute</h3>
      <h3><span class="number">6</span> attributes</h3>
      <p>textleft name textright</p>
    </div>
   </a>
</li>
<li>
   <a href="model/?id=AZWW5RJE" class="idAZWW5RJE">
   <div class="exclusive"></div>
   <div id="description">
      <h2>Model 19</h2>
      <h3><span class="number">1</span> attribute</h3>
      <h3><span class="number">6</span> attributes</h3>
      <p>textleft name textright</p>
    </div>
   </a>
</li>
<li>
   <a href="model/?id=AZWW5RJE" class="idAZWW5RJE">
   <div class="exclusive"></div>
   <div id="description">
      <h2>Model 19</h2>
      <h3><span class="number">1</span> attribute</h3>
      <h3><span class="number">6</span> attributes</h3>
      <p>textleft name textright</p>
    </div>
   </a>
</li>
<li>
   <a href="model/?id=AZWW5RJE" class="idAZWW5RJE">
   <div class="exclusive"></div>
   <div id="description">
      <h2>Model 19</h2>
      <h3><span class="number">1</span> attribute</h3>
      <h3><span class="number">6</span> attributes</h3>
      <p>textleft name textright</p>
    </div>
   </a>
</li>
</ul>

4

1 に答える 1