

<?
 
$query = "SELECT * FROM table_header WHERE id = '" . $sitepart_id . "' LIMIT 1";
$result = mysqli_query($GLOBALS['mysql_con'], $query);
$value = '';

$result = mysqli_query($GLOBALS['mysql_con'], $query);
$countRows = mysqli_num_rows($result);

if ($countRows > 0) {
    $table = @mysqli_fetch_array($result);
    echo '<div class="table-wrapper table_'.$table['id'].'">';
        echo '<table class="sitepart_table table">';
    
    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 = '';
            $count = 0;
            if (@mysqli_num_rows($result) > 0) {
                while ($rows = mysqli_fetch_array($result)) {
                     

                    if($count == 0) {
                        echo '<th>';
                    } else{
                        echo '<td>';
                    }
                        echo $rows['data'];
                    
                    if($count == 0) {
                        echo '</th>';
                    } else{
                        echo '</td>';
                    }
                    $count++;
                    
                }
            }
        }
        echo '</tr>';
        if($row == 1) {
            echo '</thead>';
        }
        
    }

        echo '</table>';
    echo '</div>';
}
?>
