title: Displaying four li's per ul's not returning result as required
body: <p>I want to display <code>&lt;ul&gt;</code> and <code>&lt;li&gt;</code> dynamically like</p>
  
  <pre><code>&lt;ul&gt;
    &lt;li&gt;&lt;/li&gt;
    &lt;/li&gt;&lt;/li&gt;
    &lt;li&gt;&lt;/li&gt;
    &lt;li&gt;&lt;/li&gt;
  &lt;/ul&gt;
  
  &lt;ul&gt;
    &lt;li&gt;&lt;/li&gt;
    &lt;/li&gt;&lt;/li&gt;
    &lt;li&gt;&lt;/li&gt;
    &lt;li&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>ie, each <code>&lt;ul&gt;</code> with 4 <code>&lt;li&gt;</code>s.</p>
  
  <p>I want to display these dynamically. I tried with the following code:</p>
  
  <pre><code>$i=0;
  foreach($query-&gt;result() as $inboxresult)
  {
          if($inboxquery-&gt;num_rows()&gt;0)
          {
              if($i%4==0)
              {
                  echo '&lt;ul class="msgdisplayul item"&gt;';
              }
              $parentid=$inboxresult-&gt;id;
              echo '&lt;li class="msgdisplayli"&gt;
               &lt;div class="msgfullarea"&gt;
                 &lt;div class="displyusrimge"&gt;
                     &lt;input type="hidden" id="status'.$inboxresult-&gt;id.'"&gt;
                     &lt;a href=""&gt;';
                      echo '&lt;img src="'.base_url().'images/friend_avatar_default.jpg" alt="Default User Avatar" /&gt;';
                      echo '&lt;/a&gt;
                  &lt;/div&gt; 
               &lt;/div&gt;
               &lt;div class="clear"&gt;&lt;/div&gt;
               &lt;/li&gt;'; 
               if($i%4==0 &amp;&amp; $i!=0)
               {
                  echo '&lt;/ul&gt;';
               }          
          }
          $i++;
  }
  </code></pre>
  
  <p>This is returning result as shown below:</p>
  
  <pre><code>&lt;ul class="msgdisplayul item"&gt;
    &lt;li class="msgdisplayli"&gt;
      &lt;div class="msgfullarea"&gt;
          &lt;div class="displyusrimge"&gt;
              &lt;input type="hidden" id="status10"&gt;
              &lt;a href=""&gt;&lt;img src="http://localhost:8080/workspace/project/images/friend_avatar_default.jpg" alt=" Default User Avatar"&gt;&lt;/a&gt;
          &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="clear"&gt;&lt;/div&gt;
     &lt;/li&gt;
     &lt;li class="msgdisplayli"&gt;
       &lt;div class="msgfullarea"&gt;
           &lt;div class="displyusrimge"&gt;
               &lt;input type="hidden" id="status7"&gt;
                &lt;a href=""&gt;&lt;img src="http://localhost:8080/workspace/project/images/friend_avatar_default.jpg" alt=" Default User Avatar"&gt;&lt;/a&gt;
            &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="clear"&gt;&lt;/div&gt;
    &lt;/li&gt;
    &lt;ul class="msgdisplayul item"&gt;&lt;li class="msgdisplayli"&gt;
      &lt;div class="msgfullarea"&gt;
          &lt;div class="displyusrimge"&gt;
              &lt;input type="hidden" id="status1"&gt;
              &lt;a href=""&gt;&lt;img src="http://localhost:8080/workspace/project/images/friend_avatar_default.jpg" alt="Default User Avatar"&gt;&lt;/a&gt;
           &lt;/div&gt;
      &lt;/div&gt;
      &lt;div class="clear"&gt;&lt;/div&gt;
     &lt;/li&gt;
     &lt;/ul&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>Can anybody help me to solve this? Thanks in advance.</p>