Hey guys, I'm not entirely sure this is the right forum for this, but I'm trying to figure out the best way to do this and I am using SQLite. I am cusing it for an Android app i am making. I'm using jQuery Mobile and PhoneGap, so we're dealing with JavaScript. I have created two tables in SQlite, "Areas" and "Restaurants". I am essentially building an app that displays restaurants in certain areas. What I am trying to do is create a nested list which would display the Areas and within the areas the Restaurants. Like so:
<ul> <li>Area 1 <ul> <li>Restaurant 1</li> <li>Restaurant 2</li> </ul> </li> <li>Area 2 <ul> <li>Restaurant 3</li> <li>Restaurant 4</li> </ul> </li> </ul> So I am using JavaScript to query the Areas and loop through them and then query the Restaurants and loop through those to create my list, but it is not working right. When I output the list, I am only getting the areas back and not the restaurants. I'm sure I'm not doing this right and there may be a way better way of doing this. Below is what I'm using. db.transaction(function(tx) { tx.executeSql('SELECT * FROM Areas;', [], function(transaction, areaResult) { var theHtml = ''; if (areaResult != null && areaResult.rows != null) { for (var i = 0; i < areaResult.rows.length; i++) { var areaRow = areaResult.rows.item(i); theHtml += '<li>' + areaRow.AreaName; tx.executeSql('SELECT * FROM Restaurants WHERE AreaID = ?;', [areaRow.AreaID], function(transaction, restaurantsResult) { theHtml = '<ul>'; for (var i2 = 0; i2 < restaurantsResult.rows.length; i2++) { var restaurantsRow = restaurantsResult.rows.item(i2); theHtml += '<li>' + restaurantsRow.RestaurantName + '</ li>'; }; theHtml += '</ul>'; } ); theHtml += '</li>'; } } $('#areas').html(theHtml); $('#areas').listview("refresh"); }); }); _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users