0) { $message = "Rows: " . $_SESSION[$id]['actual_rows']; if ($_SESSION[$id]['actual_rows'] != $_SESSION[$id]['row_count']) $message .= " (limited to " . $_SESSION[$id]['row_count'] . ")"; $list .= get_block(0, $id); // Echo the HTML snippet $text = <<
  • $message
  • $list $divs EOT; } else { $message = "Affected rows: " . pg_affected_rows($res); $text = <<

    Query completed

    $message

    EOT; } } else if ($offset != -1) // Retrieving the next batch of rows { $text = get_block($offset, $id); } else if ($row != -1) // Return a row { $text = get_row($row, $id); } echo $text; exit(); function get_block($offset, $id) { $data = ""; $last_row = (($offset + $GLOBALS['config_query_batch_size'] < $_SESSION[$id]['row_count'])) ? ($offset + $GLOBALS['config_query_batch_size']) : $_SESSION[$id]['row_count']; for ($x = $offset; $x < $last_row; $x++) { // Build the row preview list. $data .= "
  • "; $data .= $_SESSION[$id]['columns'][0] . ": " . www_clean(truncate_title($_SESSION[$id]['rows'][$x][0])) . ""; if ($_SESSION[$id]['column_count'] >= 2) $data .= "
    " . $_SESSION[$id]['columns'][1] . ": " . www_clean(truncate_title($_SESSION[$id]['rows'][$x][1])) . ""; if ($_SESSION[$id]['column_count'] >= 3) $data .= "
    " . $_SESSION[$id]['columns'][2] . ": " . www_clean(truncate_title($_SESSION[$id]['rows'][$x][2])) . ""; $data .= "
  • "; } // Add the 'Get more...' item if required if ($last_row < $_SESSION[$id]['row_count']) { if (($last_row + $GLOBALS['config_query_batch_size']) > $_SESSION[$id]['row_count']) $rows_to_fetch = ($_SESSION[$id]['row_count'] - $last_row); else $rows_to_fetch = $GLOBALS['config_query_batch_size']; if ($rows_to_fetch == 1) $data .= "
  • Get last row...
  • "; else { if ($rows_to_fetch < $GLOBALS['config_query_batch_size']) $data .= "
  • Get last " . $rows_to_fetch . " rows...
  • "; else $data .= "
  • Get " . $rows_to_fetch . " more rows...
  • "; } } return $data; } function get_row($row, $id) { $data = ""; // Build the panel for this row $data .= "
    "; $data .= "
    Row: " . ($row + 1) . "
    "; for ($col = 0; $col < $_SESSION[$id]['column_count']; $col++) { $data .= "

    " . $_SESSION[$id]['columns'][$col] . "

    " . www_clean(truncate_value($_SESSION[$id]['rows'][$row][$col])) . "
    "; } $data .= "
    "; return $data; } ?>