<?php
$odd_row = true;
$type = $collation = $func = $value = array();
/**
 * Get already set search criteria (if any)
 */

// Displays column rows for search criteria input
for ($i = 0; $i < 4; $i++): ?>
    <?php
    // After X-Axis and Y-Axis column rows, display additional criteria
    // option
    if ($i == 2): ?>
        <tr>
            <td>
                <?php echo __("Additional search criteria"); ?>
            </td>
        </tr>
    <?php endif; ?>
    <tr class="noclick <?php echo ($odd_row ? 'odd' : 'even'); ?>">
        <?php $odd_row = ! $odd_row; ?>
        <!-- Select options for column names -->
        <th>
            <select name="criteriaColumnNames[]" id="tableid_<?php echo $i; ?>" >
                <option value="pma_null">
                    <?php echo __('None'); ?>
                </option>
                <?php for ($j = 0, $nb = count($columnNames); $j < $nb; $j++): ?>
                    <?php if (isset($_POST['criteriaColumnNames'][$i])
                        && $_POST['criteriaColumnNames'][$i] == htmlspecialchars($columnNames[$j])
                    ): ?>
                        <option value="<?php echo htmlspecialchars($columnNames[$j]); ?>" selected="selected">
                            <?php echo htmlspecialchars($columnNames[$j]); ?>
                        </option>
                    <?php else: ?>
                        <option value="<?php echo htmlspecialchars($columnNames[$j]); ?>">
                            <?php echo htmlspecialchars($columnNames[$j]); ?>
                        </option>
                    <?php endif; ?>
                <?php endfor; ?>
            </select>
        </th>
        <?php
        if (isset($_POST['criteriaColumnNames'])
            && $_POST['criteriaColumnNames'][$i] != 'pma_null'
        ) {
            $key = array_search(
                $_POST['criteriaColumnNames'][$i],
                $columnNames
            );
            $properties = $self->getColumnProperties($i, $key);
            $type[$i] = $properties['type'];
            $collation[$i] = $properties['collation'];
            $func[$i] = $properties['func'];
            $value[$i] = $properties['value'];
        } ?>
        <!-- Column type -->
        <td dir="ltr">
            <?php echo (isset($type[$i]) ? htmlspecialchars($type[$i]) : ''); ?>
        </td>
        <!-- Column Collation -->
        <td>
            <?php echo (isset($collation[$i]) ? $collation[$i] : ''); ?>
        </td>
        <!-- Select options for column operators -->
        <td>
            <?php echo (isset($func[$i]) ? $func[$i] : ''); ?>
        </td>
        <!-- Inputbox for search criteria value -->
        <td>
            <?php echo (isset($value[$i]) ? $value[$i] : ''); ?>
        </td>
    </tr>
    <!-- Displays hidden fields -->
    <tr>
        <td>
            <input type="hidden"
                   name="criteriaColumnTypes[<?php echo $i; ?>]"
                   id="types_<?php echo $i; ?>"
                <?php if (isset($_POST['criteriaColumnTypes'][$i])): ?>
                    value="<?php echo $_POST['criteriaColumnTypes'][$i]; ?>"
                <?php endif; ?> />
            <input type="hidden"
                   name="criteriaColumnCollations[<?php echo $i; ?>]"
                   id="collations_<?php echo $i; ?>" />
        </td>
    </tr>
<?php endfor; ?>