A simple form that interacts with a database. Check out this gist.

Here is what that form looks like.

Then, to display the data using javascript, here is what you need to add to the bottom of form_processing.php

<script type='text/javascript'>

<?php
$sql2="SELECT * FROM dummy.logs2";
$arr = pg_fetch_all($result2);
//print_r($arr);

$php_array = $arr;
$js_array = json_encode($php_array);
echo "var javascript_array = ". $js_array . ";\n";

pg_close($conn);
?>
</script>