```
 <table class="coll activities" align="left" style="margin-top:15px;">

                    <tr>

<?php

$split = 0;
$result1=$conn->query("select * from subcategory where subcategory.maincat_id='$id'") or die(mysql_error());

while($row1 = $result1->fetch_assoc())

    {               

 $subid=$row1['subcat_id'];

 $sname=$row1['subcat_name'];

  $image=$row1['image'];

 $rowHTML = ' <a href="showresult.php?mid= <?php echo $id;?> &sid= <?php echo $subid;?> " title=" <?php echo $sname;?> ">';

  $rowHTML .= "< ?php echo '<img src="data:image/jpg;base64, '.  base64_encode($image)  .' "/>' ;?> <br />";

   $rowHTML .= "<?php echo $sname;?>";

  $rowHTML .= " </a> <br>";

echo $rowHTML;

                                $split++;   
                                if ($split%4==0){
                                echo '</tr><tr>';
                                }

                               }
                            ?>
                </tr>
                </table>

```