php - How to display the <div> as per data count displayed below? -


i have display below snippet according data available in db

<div id="testimonial-row">             <div id="testimonial">                 <ul>                      <li>"hello world"</li>                 </ul>             </div>              <div id="testimonial">                 <ul>                      <li>"hello world"</li>                 </ul>             </div>              <div id="testimonial">                 <ul>                      <li>"hello world"</li>                 </ul>             </div>         </div> 

that is, <div id="testimonial-row"> should created everytime count of data (here, hello world) becomes greater 3, hence in way if data count "16" the <div id="testimonial-row"> should created 6 times data displayed in created 6 <div> tags

so 1 tell me how implement loop make happen in php?

   echo '<div class="testimonial-row">';     ($i=1;$i<=$mysql_num_rows($res);$i++)      {         $row = mysql_fetch_array($res);                 echo '<div class="testimonial">';                 echo '  <ul>';                 echo '    <li>'.$row['field'].'</li>';                 echo '  </ul>';                 echo '</div>';          if ($i%3 == 0) echo '</div><div class="testimonial-row">';      }      echo '</div>'; 

you should not use id="testimonial-row" or id="testimonial". instead use class="testimonial-row".


Comments

Popular posts from this blog

c++ - Convert big endian to little endian when reading from a binary file -

C#: Application without a window or taskbar item (background app) that can still use Console.WriteLine() -

unicode - Are email addresses allowed to contain non-alphanumeric characters? -