0

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>
3
Contributors
4
Replies
8
Views
5 Years
Discussion Span
Last Post by vibhaJ
0

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?

0

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>
0

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.

0

$cnt

I forget to increase $cnt variable.

use $cnt++ before endforeach.

<?php 
    if(($cnt+1)%$grid==0) echo '</tr>';
    $cnt++;
  endforeach ?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.