summaryrefslogtreecommitdiff
path: root/sqlbox/view.php
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2012-11-22 12:07:35 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2012-11-22 12:31:44 +0100
commit2a14d4ae5af7dd2b08e7a16b155d45cebd3ca763 (patch)
tree7d101fcb2547ffbe92fdce444e2f0667255fa9c2 /sqlbox/view.php
parent0a8ddd6c1d9e827496b2b2d6ef466ebe55fe7183 (diff)
downloadsqltutor-plugin-2a14d4ae5af7dd2b08e7a16b155d45cebd3ca763.tar.gz
sqltutor-plugin-2a14d4ae5af7dd2b08e7a16b155d45cebd3ca763.tar.bz2
sqltutor-plugin-2a14d4ae5af7dd2b08e7a16b155d45cebd3ca763.zip
sqlbox: User html_output::table to show query result
..instead of own table code.
Diffstat (limited to 'sqlbox/view.php')
-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);
}