I'm trying to use sql.js to retrieve data from my local database and later on make modifications. I'm trying to create a select drop down, however when I try to simply display the output in a div, it only shows me the last value. I would like to have the same output as the console which is displaying all the data.
Here's my code:
<div id="test">
</div>
<script src="sql.js"></script>
<script>
var xhr = new XMLHttpRequest();
xhr.open('GET', 'test.sqlite', true);
xhr.responseType = 'arraybuffer';
xhr.onload = function(e) {
var uInt8Array = new Uint8Array(this.response);
var db = new SQL.Database(uInt8Array);
db.each("SELECT user_name FROM users",
function(row){document.getElementById("test").innerHTML = (row.user_name )});
};
xhr.send();
</script>
Thank you.
Shouldn't the line read
db.each("SELECT user_name FROM users",
function(row){document.getElementById("test").innerHTML = document.getElementById("test").innerHTML+ (row.user_name )});
};