title: Adding values dynamically to the table in Web SQL database using javascript
body: <p>I am fetching values from web service. And I have to insert those values into the table in Web SQL database.</p>
  
  <p>I have 4 records. I have inserted the following code into the loop, but only the last record is added in database and not the first 3 records.</p>
  
  <pre><code>for(var t=0;t&lt;main_category.length;t++){
          db.transaction(function(tx){
              var insertStatement="INSERT INTO main_menu(catId,catName,catImage) VALUES(?,?,?)";
              tx.executeSql(insertStatement, [menu_id, menu_name, menu_img]);
              console.log("values inserted "+ t);
          });
  }
  </code></pre>
  
  <p>I tried many solutions, following link has one of them,</p>
  
  <p><a href="https://stackoverflow.com/questions/4825455/web-sql-database-javascript-loop">Web SQL Database + Javascript loop</a></p>
  
  <p>But, it did not work. Please suggest me how can I populate the table with dynamic values.</p>