

<?
 
 
 $query = "SELECT tb.* FROM main_collection_table_link as mctl INNER JOIN table_header as tb on mctl.table_id = tb.id WHERE mctl.main_collection_id = ".$collectionData['id']." AND field_id = ".$fieldData['id']." LIMIT 1";

 $result = mysqli_query($GLOBALS['mysql_con'], $query);
 $value = '';
 
 $result = mysqli_query($GLOBALS['mysql_con'], $query);
 $countRows = mysqli_num_rows($result);
 $bodyDone = False;
 if ($countRows > 0) {
     $table = @mysqli_fetch_array($result);
     echo '<div class="table-wrapper table_'.$table['id'].'">';
         echo '<table class="sitepart_table table">';
         $count = 0;
     for($row = 1; $row <= $table['no_rows']; $row++){
         if($row == 1) {
             echo '<thead>';
         }
          
         echo '<tr>';
         
         for($column = 1; $column <= $table['no_columns']; $column++ ){
             
             $query = "SELECT * FROM table_line WHERE table_id = '" . $table['id'] . "' AND row_no = ".$row." AND column_no = ".$column." LIMIT 1";
             
             $result = mysqli_query($GLOBALS['mysql_con'], $query);
             $value = '';
            
             if (@mysqli_num_rows($result) > 0) {
                 while ($rows = mysqli_fetch_array($result)) {
                      
 
                     if($row == 1) {
                         echo '<th>';
                     } else{
                         echo '<td>';
                     }
                         echo $rows['data'];
                     
                     if($row == 0) {
                         echo '</th>';
                     } else{
                         echo '</td>';
                     }
                     
                     
                 }
             }
         }
         echo '</tr>';
         if($row == 1) {
             echo '</thead>';
         }
         
         $count++;
     }
 
         echo '</table>';
     echo '</div>';
 }
 ?>
 