function display_table($wt)
{
    global $dbhandle, $sql_strings, $button_strings, $s_watch_buffer, $s_cust;
    if ($wt['table'] == '' || !is_array($wt['columns'])) {
        return;
    }
    // if the buffer is filled, just display its content
    if (!empty($s_watch_buffer)) {
        echo $s_watch_buffer;
        echo '(' . $sql_strings['DisplBuf'] . ')';
        return;
    }
    $quote = identifier_quote($GLOBALS['s_login']['dialect']);
    $sql = 'SELECT COUNT(*) FROM ' . $quote . $wt['table'] . $quote;
    $sql .= $wt['condition'] != '' ? ' WHERE ' . $wt['condition'] : '';
    if (!($res = @fbird_query($dbhandle, $sql))) {
        echo '<br><b>Error: ' . fbird_errmsg() . '</b><br>';
        return;
    }
    $row = fbird_fetch_row($res);
    $rowcount = $row[0];
    if ($rowcount < $wt['start']) {
        $wt['start'] = $rowcount;
    }
    ob_start();
    // navigation
    echo "<table>\n<tr>\n";
    if ($wt['start'] > 1) {
        echo '<td><a href="' . url_session('watchtable.php?go=start') . '" class="act">&lt;&lt; ' . $sql_strings['Start'] . "</a></td>\n";
        echo '<td><a href="' . url_session('watchtable.php?go=prev') . '" class="act">&lt; ' . $sql_strings['Prev'] . "</a></td>\n";
    }
    $end = $wt['start'] + $wt['rows'] >= $rowcount ? $rowcount : $wt['start'] + $wt['rows'] - 1;
    $cinfo = sprintf('<b>%d - %d (%d %s)</b>', $wt['start'], $end, $rowcount, $sql_strings['Total']);
    echo '<td>&nbsp;</td><td>' . $cinfo . "</td><td>&nbsp;</td>\n";
    if ($rowcount >= $wt['start'] + $wt['rows']) {
        echo '<td><a href="' . url_session('watchtable.php?go=next') . '" class="act">' . $sql_strings['Next'] . " &gt;</a></td>\n";
        $laststart = floor(($rowcount - 1) / $wt['rows']) * $wt['rows'] + 1;
        echo '<td><a href="' . url_session('watchtable.php?go=' . $laststart) . '" class="act">' . $sql_strings['End'] . " &gt;&gt;</a></td>\n";
    }
    echo "</tr>\n</table>\n";
    // table head
    echo '<table id="watchtable" class="table table-bordered tsep">' . "\n" . "  <thead>\n" . "    <tr>\n";
    foreach ($wt['columns'] as $col) {
        $url = url_session('watchtable.php?order=' . $col);
        if ($col == $wt['order']) {
            $col = $wt['direction'] == 'ASC' ? '*&nbsp;' . $col : $col . '&nbsp;*';
        }
        echo '      <th><a href="' . $url . '">' . $col . "</a></th>\n";
    }
    if ($wt['edit'] == TRUE) {
        echo '      <th style="background-color: ' . $s_cust['color']['area'] . "\">&nbsp;</th>\n";
    }
    if ($wt['delete'] == TRUE) {
        echo '      <th style="background-color: ' . $s_cust['color']['area'] . "\">&nbsp;</th>\n";
    }
    echo "    </tr>\n" . "  </thead>\n";
    // rows
    if ($rowcount > 0) {
        print_rows_nosp($wt);
    }
    echo "</table>\n" . '<span id="tb_watch_mark_buttons" style="display:none;">' . "\n" . '<input type="submit" name="tb_watch_export" id="tb_watch_export" value="' . $button_strings['Export'] . " (0)\" class=\"bgrp\">\n" . '<input type="button" name="tb_watch_unmark" id="tb_watch_unmark" value="' . $button_strings['Unmark'] . "\" onClick=\"mwt.unmarkAll();\">\n" . "</span>\n" . js_javascript("mwt = new markableWatchtable('watchtable'," . wt_leave_columns($wt) . ");");
    // save the resulting table in the session
    $s_watch_buffer = ob_get_contents();
    ob_end_flush();
}
        ?>
">
                                <?php 
        echo $db_strings['Seconds'];
        ?>
                            </td>
                            <td>&nbsp;&nbsp;</td>
                            <td>
                                <input type="button" class="btn btn-default" name="db_refresh_select" value="<?php 
        echo $button_strings['Set'];
        ?>
" onClick="refresh_systable(this.form.db_refresh.value)">
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        <?php 
    }
    ?>
    </table>
</form>
<div id="st">
    <?php 
    if (isset($systable)) {
        echo get_systable_html($systable, $s_systable) . js_javascript("new markableIbwaTable('systable')");
    }
}
?>
</div>
Exemple #3
0
function get_result_table($result, $fieldinfo, $idx)
{
    $table = '<table class="table table-bordered table-hover" id="resulttable_' . $idx . "\">\n" . "   <tr align=\"left\">\n" . '      <th>' . implode('</th><th>', array_keys($result[0])) . "</th>\n" . "   </tr>\n";
    $cnt = count($result[0]);
    foreach ($result as $row) {
        $table .= "   <tr>\n";
        $nr = 0;
        foreach ($row as $val) {
            if ($val === NULL) {
                $val = '<i>NULL</i>';
            } elseif ($fieldinfo[$nr]['type'] == 'BLOB' && !empty($val)) {
                $val = '<i>BLOB</i>';
            } else {
                $val = trim($val);
            }
            $table .= "      <td>&nbsp;" . $val . "</td>\n";
            $nr++;
        }
        $table .= "   </tr>\n";
    }
    $table .= "</table>\n" . js_javascript("new markableIbwaTable('resulttable_" . $idx . "')");
    return $table;
}