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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:59:52+00:00 2026-06-04T17:59:52+00:00

I have a rather long code, so i think the best is I post

  • 0

I have a rather long code, so i think the best is I post it here with some additional comments as questions inside of it:

<div class="contentRow">

    <h2>Title</h2>

    <div id="frame">

        <?php

        //Get files
        $sql->query("SELECT * FROM files WHERE job = 'true'");
        $count  = count($sql->get());

        //No files to display
        if ($count == "0"){

            echo "<div class='box red'><p>No jobs found.</p></div>";

        } else{

            $sql->query("SELECT * FROM files WHERE job = 'true'");

            $i=0;

            foreach($sql->get() as $result){

                $i++;

        ?>

        <!-- Here I start printing the results and here the problems begin -->



        <!-- My goal here: Print n .jobsContainer with exactly 4 .jobContainer inside -->
        <?php if ($i % 4 == 0){ ?>
        </div><!-- CLOSE jobsContainer -->
        <?php } ?>

        <?php if ($i % 4 == 0 OR $i == 1){ ?>
        <div class="jobsContainer"><!-- OPEN jobsContainer -->
        <?php } ?>


            <!-- Print the .jobContainer -->
            <div class="jobContainer">
                content + table + form
            </div>

            <!-- My goal here: Print .jobSeperator after every 2nd  .jobContainer -->
            <?php if ($i % 2 == 0){ ?>
            <div class="jobSeperator">&nbsp;</div>
            <?php } ?>


        <!-- CLOSE loop -->
        <?php  } }?>


    </div><!-- jobsFrame -->

    <div class="clear"></div>

</div><!-- contentRow -->

The desired output should look like this:

enter image description here

My problem is following:

It seems that there are only 3 elements included in the first container, but after that there are 4. Therefore also the seperators are kinda messed up and it looks like this:

enter image description here

It seems that the problem is not applying to the .jobSeperator, as it does always get included after every 2th container, however it gets messed up too, because of the fact that in the first .jobsContainer there are just 3 sub containers.

I dont get why in the first .jobsContainer there are just 3 sub containers, but from than on there are, as desired, 4, but probably it is obvious and I just dont see it…

p.s. If I set the code to print 5 .jobContainer inside one .jobsContainer, than there are printed 4 in the first .jobsContainer and from than on 5 in every following .jobsContainer

  • 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-06-04T17:59:55+00:00Added an answer on June 4, 2026 at 5:59 pm

    First of all, you should not keep your SQL logic mixed with HTML.

    Anyway. The idea is that you need to output a separator after each second item. The testcase i would look at would be like this.

    1 2
    ---
    3 4
    ***
    5 6
    ---
    7
    

    And the code for writing it would be:

    $i = 0;
    foreach( /* some array */ as $data ){
    
        $i++;
        if ( ($i - 1) % 2 === 0 ){
    
            if ( ($i - 1) % 4 === 0 ){
    
                echo '<br />***<br />';
            } else {
    
                echo '<br />---<br />';
            }            
        }
    
        echo $i, ' ';
    }
    

    This would reproduce the structure above (never tested).

    As for the separation of layout and rest of application logic, you might look in to this article. It will show a quite simple way, without a need of additional 3rd party libraries.

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

Sidebar

Related Questions

I have a rather long switch-case statement. Some of the cases are really short
I have some rather long (~150 character) django queries. What's the preferred way to
I have a task that takes a rather long time and should run in
Imagine I have the following code: class A { [UsefulAttribute(foo)] B var1; [UsefulAttribute(bar)] B
I have a question! I already have some code, which is being auto-documented by
I have rather large project that uses ICU regex classes. Basically it might run
Have a rather simple question. Does anyone knows if i can use jparallax both
I have a rather enormous project in which I'm trying to retrofit in-memory data.
I have a rather large SQL file which starts with the byte order marker
I have a rather huge query that is needed in several stored procedures, and

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.