summaryrefslogtreecommitdiff
path: root/sqlbox
diff options
context:
space:
mode:
Diffstat (limited to 'sqlbox')
-rw-r--r--sqlbox/view.php21
1 files changed, 9 insertions, 12 deletions
diff --git a/sqlbox/view.php b/sqlbox/view.php
index b45924b..2169ab0 100644
--- a/sqlbox/view.php
+++ b/sqlbox/view.php
@@ -88,19 +88,16 @@ if (isset($data->sqlbox_query)) {
if (!$result)
error("Query failed: ".pg_last_error($db));
- echo "<table style=\"border: 1px;\">";
+ $table = new html_table();
$n = pg_num_fields($result);
- for ($i = 0; $i < $n; $i++) {
- echo "<th>".pg_field_name($result, $i)."</th>";
- }
- while($row=pg_fetch_row($result)){
- echo "<tr>";
- foreach($row as $val) {
- echo "<td>$val</td>";
- }
- echo "</tr>";
- }
- echo "</table>";
+ for ($i = 0; $i < $n; $i++)
+ $table->head[] = pg_field_name($result, $i);
+ $table->align = array_fill(0, $n, 'left');
+ while ($row = pg_fetch_row($result))
+ $table->data[] = $row;
+
+ echo html_writer::table($table);
+
pg_close($db);
}