Php: spread data in several columns

I need your help with this small issue as my developing level is not the best In the room ( faraway :slight_smile: )

I would like to spread the results of my SQL request in 3 columns.

After the first 37 entries, I would like the entries 38 to 74 are filling the column #2, and column #3 over 74…

I hope it is clear.

please find below the code of my page:

<title>TITLE</title>
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@700;800;900&display=swap" rel="stylesheet">
<style>
body {background-color: #000000;}
table {
    background-color: #000000;
    border-collapse: collapse;
    width: 100%;

}
table, .table {
    color: #fff;
      font-family: "Montserrat", sans-serif;
  font-size: 18px;
  font-weight:800;
font-weight:Extra-bold;
}
tr:nth-child(even) {
background-color: #60451e;
}
</style>
<div class="container">	
	<div class="row">
		<?php
		include_once("inc/db_connect.php");
		$sqlQuery = "SELECT  name, GROUP_CONCAT(id ORDER BY id SEPARATOR ' | ') as grouped_id  FROM developers GROUP BY name";
		$resultSet = mysqli_query($conn, $sqlQuery) or die("database error:". mysqli_error($conn));
		?>
		<table id="editableTable" class="table table-bordered">

			<tbody>
				<?php while( $developer = mysqli_fetch_assoc($resultSet) ) { ?>
				   <tr id="<?php echo $developer ['id']; ?>">
				   <td><?php echo $developer ['name']; ?><br>&emsp;  <span style="color: #ffc000">BOXES > <?php echo $developer ['grouped_id']; ?></span></td>
				   </tr>
				<?php } ?>
			</tbody>
		</table>	
  </div>
</div>

and I would like to keep a formatting similar to this for each entry:

echo $developer ['name']; ?><br>&emsp;  <span style="color: #ffc000">BOXES > <?php echo $developer ['grouped_id']; ?></span>

Thank you in advance

You may wish to use a HTML table, but you’re still stuck with populating it out of order (in that tables fill left to right, not top to bottom) - so would need to do something like use the PHP to populate a JavaScript array and fill the table from that.

Another approach could be to use flex (CSS display) items, set it to vertical, and its element width to 33% thus locking in 3 columns, the its height to 2.7% (being 37 / 100). You will have a problem though if the total number of records is greater than 111 as you’ll have no place for them in this approach.

These are my admittedly low-tech solutions, there could be a smarter & cleaner way of doing what you need here - so let’s hope someone else comes up with them :wink:

Not a Cakephp question but i think this will accomplish what you asked.
You need three queries and limit them with the range you want.
Then in each html table column you iterate through each of the result sets
for the three queries

<?php
		include_once("inc/db_connect.php");
        $mainQuery = 'SELECT  name, GROUP_CONCAT(id ORDER BY id SEPARATOR ' | ') as grouped_id  FROM developers GROUP BY name limit';
        $sqlQuery1 = $mainQuery . ' 0,37';
        $sqlQuery2 = $mainQuery . ' 37,74';
        $sqlQuery3 = $mainQuery . ' 74,111';
        $resultSet1 = mysqli_query($conn, $sqlQuery1) or die("database error:". mysqli_error($conn));
        $resultSet2 = mysqli_query($conn, $sqlQuery2) or die("database error:". mysqli_error($conn));
        $resultSet3 = mysqli_query($conn, $sqlQuery3) or die("database error:". mysqli_error($conn));
		?>
		<table id="editableTable" class="table table-bordered">

			<tbody>
				<?php while( $developer1 = mysqli_fetch_assoc($resultSet1) ) { ?>
				   <tr id="<?php echo $developer1 ['id']; ?>">
				   <td><?php echo $developer1 ['name']; ?><br>&emsp;  <span style="color: #ffc000">BOXES > <?php echo $developer ['grouped_id']; ?></span></td>
				   </tr>
				<?php } ?>
				<?php while( $developer2 = mysqli_fetch_assoc($resultSet2) ) { ?>
				   <tr id="<?php echo $developer2 ['id']; ?>">
				   <td><?php echo $developer2 ['name']; ?><br>&emsp;  <span style="color: #ffc000">BOXES > <?php echo $developer ['grouped_id']; ?></span></td>
				   </tr>
				<?php } ?>
				<?php while( $developer3 = mysqli_fetch_assoc($resultSet3) ) { ?>
				   <tr id="<?php echo $developer3 ['id']; ?>">
				   <td><?php echo $developer3 ['name']; ?><br>&emsp;  <span style="color: #ffc000">BOXES > <?php echo $developer ['grouped_id']; ?></span></td>
				   </tr>
				<?php } ?>
			</tbody>
		</table>