Hi everybody,

What is the problem in this code,loop does not working .
layout page display loop.
i need 12 columns. in page layout.

plz help me.

<div  class="planbooks"> 
<b><?php echo date(" 'F 'y") ?></b>
<?php $i=0;


foreach ($planbooks as $planbook): ?>
  for($i = 0; $i <=15; $i++)
{
   if(!($i % $12) && $i > 0)
    {
</div> }
<div class="planbooks">




<p><div id="planbook-content" class="float" >

<a class="musttry" href="#" onclick="musttry_add()" >MustTry</a>

<div><img src="/uploads/planbook/<?php echo $planbook['photo'] ?>" alt="" /></div>

<div>
<span class="field-label"> Title: <?php echo $planbook['title_name'] ?></span></div></br>

 Country: <?php echo $planbook['country_id'] ?></span><br /></td></tr>
 <div>
 <span class="field-label">Area: <?php echo $planbook['zone_id'] ?></span><br /></div>
 <div>
 <span class="field-label">Place: <?php echo $planbook['place'] ?></span><br /></div>
 <div><span class="field-label">Occasion: <?php echo $planbook['occasion'] ?></span></div>
<div> <span class="field-label">Itinerary: <?php echo $planbook['itinerary'] ?></span><br /></div>
 <div><span class="field-label">Date: <?php echo $planbook['date'] ?></span><br></div>
<div><span class="field-label">Description: <?php echo $planbook['description'] ?></span><br /></div>
 </div>

}

<?php 

 endforeach ?>
 </div>
 </p>
</div>

Immidiately, I can see that the endforeach needs a semicolon. Also, lines 7-11 look like they need to be inside a <?php ... ?> block. Outside of these observations, are you getting any specific error messages?

Try this::

<div class="planbooks">
<b><?php echo date(" 'F 'y") ?></b>
<table width="100%" border="0" cellspacing="1" cellpadding="5">
  <?php 
  $grid = 12;
  $cnt = 0;
  foreach ($planbooks as $planbook): 
    if($cnt==0 || $cnt%$grid==0) echo '<tr>';
  ?>
    <td><div id="planbook-content" class="float" >
      <a class="musttry" href="#" onclick="musttry_add()" >MustTry</a>
      <div><img src="/uploads/planbook/<?php echo $planbook['photo'] ?>" alt="" /></div>
      <div> <span class="field-label"> Title: <?php echo $planbook['title_name'] ?></span></div>
      </br>
      Country: <?php echo $planbook['country_id'] ?></span><br /></td>
  </tr>
  <div> <span class="field-label">Area: <?php echo $planbook['zone_id'] ?></span><br />
  </div>
  <div> <span class="field-label">Place: <?php echo $planbook['place'] ?></span><br />
  </div>
  <div><span class="field-label">Occasion: <?php echo $planbook['occasion'] ?></span></div>
  <div> <span class="field-label">Itinerary: <?php echo $planbook['itinerary'] ?></span><br />
  </div>
  <div><span class="field-label">Date: <?php echo $planbook['date'] ?></span><br>
  </div>
  <div><span class="field-label">Description: <?php echo $planbook['description'] ?></span><br />
  </div>
    </div> 
    </td>  
  <?php 
    if(($cnt+1)%$grid==0) echo '</tr>';
  endforeach ?>
</table>
</div>

hi,Thanks for your reply,i tried this code.all the layout records display rows.but i need column wise.anybody plz help me.

col1 col2 col3 .....................col12

plz help me.

$cnt

I forget to increase $cnt variable.

use $cnt++ before endforeach.

<?php 
    if(($cnt+1)%$grid==0) echo '</tr>';
    $cnt++;
  endforeach ?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.