i am working on a search engine in jquery mobile I want to split words in an array for a database search the code I am using is:
var sear=$("#search").val();
var db = openDatabase("Database", "1.0", "PhoneGap Demo", 200000);
db.transaction(function (tx) {
tx.executeSql("SELECT * FROM DEMO WHERE (D_Indications LIKE ?);",
["%"+sear+"%"],
function (tx, results) {
$('#output').show();
var len = results.rows.length, i;
var row=results.rows.item(i);
for (i = 0; i < len; i++) {
$('#output2').append('<tr><td>'+ row.Cat_name +'</td><td>'+ row.Drug_Caty +'</td><td>'+ row.G_Name +'</td><td>'+ row.B_Name +'</td><td>'+ row.D_Indications +'</td></tr>').trigger('create');
}
});
});
I want it to split words after space and search each word individually in database. For eg. if a user types "hello world" I want it to search "%hello%" & "%world%" separately in the database