Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 876231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T11:24:03+00:00 2026-05-15T11:24:03+00:00

I have a webapp that I’m building, and have just started with SQLite. I

  • 0

I have a webapp that I’m building, and have just started with SQLite. I have been able to create my form, open the database I created, create the table, and fields i need, and enter data into the fields.

Now I’m trying to read the data back out with a SELECT statement, to show it on screen and as a list of the columns. I just don’t know the syntax for the SELECT statemnt in javascript or HTML5 beyond

‘SELECT * FROM MyTable’…I know it can be done, just need some help with the syntax of getting the results onto the screen.

I start with this.

   

var db = window.openDatabase('TabOrder', '', 'Bar Tab Orders', 2500000);

 function insertDrinks(category, drinkname, our_cost, cust_cost){
  db.transaction(function(tx){
   tx.executeSql('INSERT INTO Drinks (category, drinkname, our_cost, cust_cost) VALUES (?, ?, ?, ?)', [category, drinkname, out_cost, cust_cost]);
  });
 }

 $(document).ready(function() {
  db.transaction(function(tx) {
   tx.executeSql('CREATE TABLE IF NOT EXISTS Drinks(id INTEGER PRIMARY KEY Autonumber, category TEXT, drinkname TEXT, our_cost FLOAT(6,2), cust_cost FLOAT(7,2))', []);
  });
 });
 

I later have this….



 View Cat / Drink List
 
 function readDrinks(id, category, drinkname, our_cost, cust_cost){
  db.transaction(function(tx) {
   tx.executeSql('SELECT * FROM Drinks', [id, category, drinkname, our_cost, cust_cost]);
  });
 document.write(id, category + " are the categories.");
 }
 


I just tried to piece it together, and have no idea what i’m doing with it beyond the basic SQL.

Any help is greatly appreciated…and this is for a client side DB, not one connecting to the web.

thanks….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T11:24:03+00:00Added an answer on May 15, 2026 at 11:24 am

    See the spec and this Apple tutorial. In short, you need to add data and error callbacks. Also, you should be passing an empty array (or null) because your query has no parameters.

    db.transaction(function(tx) {
       tx.executeSql('SELECT * FROM Drinks', 
                     [],
                     function(tx, results)
                     {
                       // results is a http://dev.w3.org/html5/webdatabase/#sqlresultset .  
                       // It has insertId, rowsAffected, and rows, which is
                       // essentially (not exactly) an array of arrays. 
                     },
                     function(tx, error)
                     {
    
                     }
       );
    });
    

    It’s up to you whether to use named or anonymous functions.

    EDIT: I made a working demo at http://jsfiddle.net/WcV6Y/7/ . It’s tested in Chrome 5.0.375.70.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.