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 4021116
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:18:43+00:00 2026-05-20T10:18:43+00:00

Pretty much I have a code like below that I’m trying to add </tr><tr>

  • 0

Pretty much I have a code like below that I’m trying to add </tr><tr> to after every 6 results.

echo "<table><tr>";

$query="SELECT * WHERE id='$id' ORDER BY date ASC";
$result=mysql_query($query);

if (mysql_num_rows($result) > 0) {
while($rts = mysql_fetch_array($result)){

$cdata1 = $rts['cdata1'];
$cdata2 = $rts['cdata2'];

echo "<td>$cdata1 and $cdata2</td>";

}
}else{
echo "<td>no results</td>";
}
echo "</tr></table>";
  • 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-20T10:18:43+00:00Added an answer on May 20, 2026 at 10:18 am
    echo "<table><tr>";
    
    $query="SELECT * WHERE id='$id' ORDER BY date ASC";
    $result=mysql_query($query);
    
    $i = 0;
    
    if (mysql_num_rows($result) > 0) {
    while($rts = mysql_fetch_array($result)){
    
    $cdata1 = $rts['cdata1'];
    $cdata2 = $rts['cdata2'];
    
    echo "<td>$cdata1 and $cdata2</td>";
    
    if(++$i % 6 == 0) {
       echo '</tr><tr>';
    }
    
    }
    }else{
    echo "<td>no results</td>";
    }
    echo "</tr></table>";
    

    UPD:

    Whats means if(++$i % 6 == 0) code:

    1. ++$i equals $i = $i + 1;
    2. $i % 6 means $i modulo 6
    3. If $i modulo 6 equals 0 then echo </tr><tr>

    So we can write it as:

    $i = $i + 1;
    if($i % 6 == 0) {
       echo '</tr><tr>';
    }
    

    http://php.net/manual/en/internals2.opcodes.mod.php

    http://php.net/manual/en/language.operators.increment.php

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

Sidebar

Related Questions

Pretty much what the title says really. We have some code that is .NET
I have heard mention that some desktop applications are pretty much just wrappers for
Pretty much every other editor that isn't a vi descendant (vim, cream, vi-emu) seems
I have pretty much finished my first working Symbian application, but in my hastened
I have a pretty much default installation on mysql on Windows 2003. I am
I have this syntax which works (since it's from the API, pretty much) <%
Pretty much as the question asks. Answers preferably in pseudo code and referenced. The
I have been writing some code that creates a generic blog. Its features are
pretty much what the title says. I am using an Ajax Drop Down as
Pretty much what the question says. What's the difference between the two classes of

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.