diff options
Diffstat (limited to 'sqlbox/view.php')
-rw-r--r-- | sqlbox/view.php | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/sqlbox/view.php b/sqlbox/view.php index ee30811..0f371b8 100644 --- a/sqlbox/view.php +++ b/sqlbox/view.php @@ -77,7 +77,24 @@ echo $OUTPUT->heading('Yay! It works!'); $form = new mod_sqlbox_form($PAGE->url->out(false)); $form->display(); -print_r($form->get_data()); +$data = $form->get_data(); + +echo $OUTPUT->heading('Query: '.$data->query); +if (isset($data->query)) { + $db = pg_connect("host=localhost dbname=sqlbox user=sqlbox password=foobar"); + if (!db) + error("Failed to connect to sqlbox db"); + + $result = pg_query($db, $data->query); + if (!$result) + error("Query failed!"); + + while($row=pg_fetch_row($result)){ + print_r($row); + echo "<br />\n"; + } +} + // Finish the page echo $OUTPUT->footer(); |