Nested repeat region in 3 columns

Hi,

I have a normal nested repeat list (see attachment image).

It comes in just one table column.

How can with this CODE  to have this list split in 3 columns instead of 1 column?

Please GURU requiered,
thanks.


mysql_select_db($database_lawyers_conn, $lawyers_conn);
$query_master1category_cat = "SELECT * FROM category_cat ORDER BY name_cat";
$master1category_cat = mysql_query($query_master1category_cat, $lawyers_conn) or die(mysql_error());
$row_master1category_cat = mysql_fetch_assoc($master1category_cat);
$totalRows_master1category_cat = mysql_num_rows($master1category_cat);
 
mysql_select_db($database_lawyers_conn, $lawyers_conn);
$query_detail2subcategory_sub = "SELECT * FROM subcategory_sub WHERE idcat_subcat=123456789 ORDER BY name_subcat";
$detail2subcategory_sub = mysql_query($query_detail2subcategory_sub, $lawyers_conn) or die(mysql_error());
$row_detail2subcategory_sub = mysql_fetch_assoc($detail2subcategory_sub);
$totalRows_detail2subcategory_sub = mysql_num_rows($detail2subcategory_sub);
 
CODE:
 
<table border="1">
  <tr>
    <?php
  do { // horizontal looper version 3
?>
      <td><?php echo $row_Recordset1['name_cat']; ?></td>
      <?php
    $row_Recordset1 = mysql_fetch_assoc($Recordset1);
    if (!isset($nested_Recordset1)) {
      $nested_Recordset1= 1;
    }
    if (isset($row_Recordset1) && is_array($row_Recordset1) && $nested_Recordset1++ % 3==0) {
      echo "</tr><tr>";
    }
  } while ($row_Recordset1); //end horizontal looper version 3
?>
  </tr>
</table>

Open in new window

screenshot-14281-62.47.240.240.png
FernanditosAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

HainKurtSr. System AnalystCommented:
pseudo code...
step = ceiling(total rec / 3)
 
function Write_section(n)
  your existing logic here, but filter main records ((n-1)*step) + 1 .. n*step
end
 
<table>
<tr>
  <td>
 
    write_section(1)
 
  </td>
</tr>
<tr>
  <td>
 
    write_section(2)
 
  </td>
</tr>
<tr>
  <td>
 
    write_section(3)
 
  </td>
</tr>
</table>

Open in new window

0
FernanditosAuthor Commented:
Hi

I'm sorry this is the right code to make the nested repeat region in 1 column.

But, I really can't make your solution work.

Could you please make the example using the real code ?

Please, thanks.

 
<table border="1">
  <?php do { ?>
    <tr>
      
      <td><b><?php echo $row_master1category_cat['name_cat']; ?></b></td>
    </tr>
    <?php
  if ($totalRows_master1category_cat>0) {
    $nested_query_detail2subcategory_sub = str_replace("123456789", $row_master1category_cat['id_cat'], $query_detail2subcategory_sub);
    mysql_select_db($database_lawyers_conn);
    $detail2subcategory_sub = mysql_query($nested_query_detail2subcategory_sub, $lawyers_conn) or die(mysql_error());
    $row_detail2subcategory_sub = mysql_fetch_assoc($detail2subcategory_sub);
    $totalRows_detail2subcategory_sub = mysql_num_rows($detail2subcategory_sub);
    $nested_sw = false;
    if (isset($row_detail2subcategory_sub) && is_array($row_detail2subcategory_sub)) {
      do { //Nested repeat
?>
      <tr>
        <td>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $row_detail2subcategory_sub['name_subcat']; ?></td>
      </tr>
      <?php
      } while ($row_detail2subcategory_sub = mysql_fetch_assoc($detail2subcategory_sub)); //Nested move next
    }
  }
?>
    <?php } while ($row_master1category_cat = mysql_fetch_assoc($master1category_cat)); ?>
</table>

Open in new window

0
FernanditosAuthor Commented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.