Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript
Javascript General Javascript discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 23rd, 2014, 07:05 PM
Authorized User
Join Date: May 2013
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to you pass variables into a web sql limit clause

I'm using web sql to store and retrieve data to and from a mobile device's local memory. I wrote the following query for the retrieval part which works just fine

   			var sql = "SELECT * FROM messages ORDER BY timestamp DESC LIMIT 0,20";
    			transaction.executeSql (sql, undefined, function (transaction, result){

                                     //Get rows


But I want to use variables in place of the numbers because the code will be reused in several different instances. So my new code reads like this


                        var index = 0;

                        var lim = 20;

   			var sql = "SELECT * FROM messages ORDER BY timestamp DESC LIMIT index,lim";
    			transaction.executeSql (sql, undefined, function (transaction, result){

                                     //Get rows


Unfortunately, this doesn't work and I don't even get any errors. Who knows what I'm doing wrong?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Pass Variables obrienkev C# 2005 1 July 18th, 2008 03:58 AM
How do I Pass Session Variables cdanczak Classic ASP Professional 0 November 27th, 2007 10:42 AM
how can I pass variables to vb? astarti Beginning VB 6 4 September 5th, 2007 08:43 AM
Is it better to pass variables to a function? stephen_c_ Beginning PHP 3 November 4th, 2005 05:07 AM
How Do I Pass 2 Variables in Javascript Lucy Javascript 2 December 13th, 2003 11:25 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.