WebSQL has been deprecated but it is still useful for some applications at this time.
This is my table, I am using KnockoutJS:
<table class='producttable'>
<tr>
<th>Name</th>
<th>Description</th>
<th>Price</th>
</tr>
<tbody data-bind="foreach: products">
<tr>
<td><input data-bind='value: name' /></td>
<td><input data-bind='value: description' /></td>
<td><input data-bind='value: price' /> </td>
</tr>
</tbody>
</table>
I have been able to save/insert data into WebSQL like this:
function saveproduct(product) {
db.transaction(function (tx) {
tx.executeSql('INSERT INTO products (name, description, price) VALUES (?, ?, ?)',
[product.name, product.description, product.price]);
});
}
I am unsure on how to update one row of data in WebSQL.
I have tried this below, but it does not work. Am I heading in the right direction?
function updateproduct(product) {
db.transaction(function (tx) {
tx.executeSql('UPDATE products SET name=? WHERE id=?', [product.title]);
});
}