<?php for ($i = 0, $l = count($GLOBALS['PMD']["TABLE_NAME"]); $i < $l; $i++) :
    $t_n = $GLOBALS['PMD']["TABLE_NAME"][$i];
    $t_n_url = htmlspecialchars($GLOBALS['PMD_URL']["TABLE_NAME"][$i]); ?>
    <input name="t_x[<?= $t_n_url; ?>]" type="hidden" id="t_x_<?= $t_n_url; ?>_" />
    <input name="t_y[<?= $t_n_url; ?>]" type="hidden" id="t_y_<?= $t_n_url; ?>_" />
    <input name="t_v[<?= $t_n_url; ?>]" type="hidden" id="t_v_<?= $t_n_url; ?>_" />
    <input name="t_h[<?= $t_n_url; ?>]" type="hidden" id="t_h_<?= $t_n_url; ?>_" />
    <!-- Why should we put styles here?! -->
    <table id="<?= $t_n_url; ?>"
           cellpadding="0"
           cellspacing="0"
           class="pmd_tab"
           style="position:absolute; left:<?= (isset($tab_pos[$t_n]) ? $tab_pos[$t_n]["X"] : rand(20, 700)); ?>px; top:<?= (isset($tab_pos[$t_n]) ? $tab_pos[$t_n]["Y"] : rand(20, 550)); ?>px; display:<?= (isset($tab_pos[$t_n]) || $display_page == -1) ? 'block;' : 'none';?>; z-index: 1;">
        <thead>
            <tr class="header">
                <?php if (isset($_REQUEST['query'])) : ?>
                    <td class="select_all">
                        <input class="select_all_1"
                               type="checkbox"
                               style="margin: 0;"
                               value="select_all_<?= htmlspecialchars($t_n_url); ?>"
                               id="select_all_<?= htmlspecialchars($t_n_url); ?>"
                               title="select all"
                               pmd_url_table_name="<?= htmlspecialchars($t_n_url); ?>"
                               pmd_out_owner="<?= htmlspecialchars($GLOBALS['PMD_OUT']['OWNER'][$i]); ?>">
                    </td>
                <?php endif; ?>
                <td class="small_tab"
                    title="<?= __('Show/hide columns'); ?>"
                    id="id_hide_tbody_<?= $t_n_url; ?>"
                    table_name="<?= htmlspecialchars($t_n_url); ?>"
                    onmouseover="this.className='small_tab2';"
                    onmouseout="this.className='small_tab';" ><?= (! isset($tab_pos[$t_n]) || ! empty($tab_pos[$t_n]["V"])) ? 'v' : '&gt;'; ?>
                </td>
                <td class="small_tab_pref small_tab_pref_1"
                    table_name_small="<?= htmlspecialchars($GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i]); ?>"
                    onmouseover="this.className='small_tab_pref2 small_tab_pref_1';"
                    onmouseout="this.className='small_tab_pref small_tab_pref_1';" >
                    <img src="<?= $_SESSION['PMA_Theme']->getImgPath('pmd/exec_small.png'); ?>"
                         title="<?= __('See table structure'); ?>" />
                </td>
                <td id="id_zag_<?= htmlspecialchars($t_n_url); ?>"
                    class="tab_zag nowrap tab_zag_noquery"
                    onmousedown="cur_click=document.getElementById('<?= $t_n_url; ?>');"
                    table_name="<?= htmlspecialchars($t_n_url); ?>"
                    query_set="<?= isset($_REQUEST['query']) ? 1 : 0 ; ?>" >
                    <span class="owner">
                        <?= $GLOBALS['PMD_OUT']["OWNER"][$i]; ?>
                    </span>
                    <?= $GLOBALS['PMD_OUT']['TABLE_NAME_SMALL'][$i]; ?>
                </td>
                <?php if (isset($_REQUEST['query'])) : ?>
                    <td class="tab_zag tab_zag_query"
                        id="id_zag_<?= htmlspecialchars($t_n_url); ?>_2"
                        table_name="<?= htmlspecialchars($t_n_url); ?>"
                        onmousedown="cur_click=document.getElementById('<?= htmlspecialchars($t_n_url); ?>');">
                    </td>
               <?php endif; ?>
            </tr>
        </thead>
        <tbody id="id_tbody_<?= $t_n_url; ?>" style="<?= (isset($tab_pos[$t_n]) && empty($tab_pos[$t_n]["V"])) ? 'display: none' : ''; ?>">
            <?php $display_field = PMA_getDisplayField(
                $_GET['db'],
                $GLOBALS['PMD']["TABLE_NAME_SMALL"][$i]
            );
            for ($j = 0, $id_cnt = count($tab_column[$t_n]["COLUMN_ID"]); $j < $id_cnt; $j++) :
                $tmpColumn = $t_n . "." . $tab_column[$t_n]["COLUMN_NAME"][$j];
                $click_field_param = array(
                    $GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i],
                    urlencode($tab_column[$t_n]["COLUMN_NAME"][$j])
                );
                if (!PMA\libraries\Util::isForeignKeySupported($GLOBALS['PMD']['TABLE_TYPE'][$i])) {
                    $click_field_param[] = isset($tables_pk_or_unique_keys[$tmpColumn]) ? 1 : 0;
                } else {
                    // if foreign keys are supported, it's not necessary that the
                    // index is a primary key
                    $click_field_param[] = isset($tables_all_keys[$tmpColumn]) ? 1 : 0;
                }
                ?>
                <tr id="id_tr_<?= htmlspecialchars($GLOBALS['PMD_URL']["TABLE_NAME_SMALL"][$i]); ?>.<?= htmlspecialchars($tab_column[$t_n]["COLUMN_NAME"][$j]); ?>"
                    <?= ($display_field == $tab_column[$t_n]["COLUMN_NAME"][$j]) ? 'class="tab_field_3"' : 'class="tab_field"'; ?>
                    onmouseover="old_class = this.className; this.className = 'tab_field_2';"
                    onmouseout="this.className = old_class;"
                    click_field_param="<?= htmlspecialchars(implode($click_field_param, ',')); ?>">
                    <?php if (isset($_REQUEST['query'])) : ?>
                        <td class="select_all">
                            <input class="select_all_store_col"
                                   value="<?= htmlspecialchars($t_n_url) , urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]); ?>"
                                   type="checkbox"
                                   id="select_<?= htmlspecialchars($t_n_url); ?>._<?= urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]); ?>"
                                   style="margin: 0;"
                                   title="select_<?= urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]); ?>"
                                   store_column_param="<?= urlencode($GLOBALS['PMD_OUT']["TABLE_NAME_SMALL"][$i]); ?>,<?= htmlspecialchars($GLOBALS['PMD_OUT']["OWNER"][$i]); ?>,<?= urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]); ?>">
                        </td>
                    <?php endif; ?>
                    <td width="10px" colspan="3" id="<?= $t_n_url; ?>.<?= urlencode($tab_column[$t_n]["COLUMN_NAME"][$j]); ?>">
                        <div class="nowrap">
                            <?php if (isset($tables_pk_or_unique_keys[$t_n . "." . $tab_column[$t_n]["COLUMN_NAME"][$j]])) : ?>
                                <img src="<?= $_SESSION['PMA_Theme']->getImgPath('pmd/FieldKey_small.png'); ?>" alt="*" />
                            <?php else :
                                $type = 'pmd/Field_small';
                                if (strstr($tab_column[$t_n]["TYPE"][$j], 'char')
                                    || strstr($tab_column[$t_n]["TYPE"][$j], 'text')
                                ) {
                                    $type .= '_char';
                                } elseif (strstr($tab_column[$t_n]["TYPE"][$j], 'int')
                                    || strstr($tab_column[$t_n]["TYPE"][$j], 'float')
                                    || strstr($tab_column[$t_n]["TYPE"][$j], 'double')
                                    || strstr($tab_column[$t_n]["TYPE"][$j], 'decimal')
                                ) {
                                    $type .= '_int';
                                } elseif (strstr($tab_column[$t_n]["TYPE"][$j], 'date')
                                    || strstr($tab_column[$t_n]["TYPE"][$j], 'time')
                                    || strstr($tab_column[$t_n]["TYPE"][$j], 'year')
                                ) {
                                    $type .= '_date';
                                }
                                ?>
                                <img src="<?= $_SESSION['PMA_Theme']->getImgPath($type); ?>.png" alt="*" />
                            <?php endif; ?>
                            <?= htmlspecialchars(
                                $tab_column[$t_n]["COLUMN_NAME"][$j] . " : "
                                . $tab_column[$t_n]["TYPE"][$j],
                                ENT_QUOTES
                            ); ?>
                        </div>
                    </td>
                    <?php if (isset($_REQUEST['query'])) : ?>
                        <td class="small_tab_pref small_tab_pref_click_opt"
                            onmouseover="this.className='small_tab_pref2 small_tab_pref_click_opt'"
                            onmouseout="this.className='small_tab_pref small_tab_pref_click_opt'"
                            Click_option_param="pmd_optionse,<?= urlencode($tab_column[$t_n]['COLUMN_NAME'][$j]); ?>,<?= $GLOBALS['PMD_OUT']['TABLE_NAME_SMALL'][$i]; ?>" >
                            <img src="<?= $_SESSION['PMA_Theme']->getImgPath('pmd/exec_small.png'); ?>" title="options" />
                        </td>
                    <?php endif; ?>
                </tr>
            <?php endfor; ?>
        </tbody>
    </table>
<?php endfor; ?>
