Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6033189
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T05:26:51+00:00 2026-05-23T05:26:51+00:00

I am using Smarty to output an array to an HTML table. I want

  • 0

I am using Smarty to output an array to an HTML table. I want each row of the table to have no more than 8 items in it. If the array has more than 8 items then the code would make a new row for the overflowing items.

How can I do this? Is this clear?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T05:26:52+00:00Added an answer on May 23, 2026 at 5:26 am

    It’s been a long time since I’ve used Smarty, but you should be able to do this like this:

    <tr>
    {foreach from=$items key=myId item=i name=foo}
      {if $smarty.foreach.foo.index % 8 == 0 && $smarty.foreach.foo.index > 0 }
         </tr><tr>
      {/if}
      <td>{$i.label}</td>
    {/foreach}
    </tr>
    

    The modulus operator only returns 0 if the index is dividable by 8, So before every 9th item it adds a new row. We don’t want this for the first item to happend so let’s check that as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a php variable which has html/smarty code in it $x='<a href={$link} >{$title}</a>';
I'm using smarty for my site, and I'm trying to loop through an array
I am doing a little learning on php and and html using smarty to
How do you include Javascript from a CDN source using Smarty? We have code
I want to access the value of thumbnail using Smarty but I need some
I have two tables: CREATE TABLE items ( root_id integer NOT NULL, id serial
I am using smarty php template and sql server I have the following tables
Im using smarty and mysql_real_escape_string() for user input, and when I insert some code
I found that using Smarty with PHP, sometimes extra time will need to be
I'm using Smarty templates which call object methods. I've put the code on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.