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 5958743
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T18:35:11+00:00 2026-05-22T18:35:11+00:00

i have this code for my webdb, i try to delete an item and

  • 0

i have this code for my webdb, i try to delete an item and set the order to the other one, but it change only the last item.

for (var i=ordine2; i < lunghezza-1+ordine2; i++) {
    var db = miodb.webdb.db;
    var ordine3=ordine2+i+1;
    var ordine4=ordine2+i;
       db.transaction(function(tx){
        tx.executeSql("UPDATE todo SET ordine = " + "'" + ordine4 + "'" + " WHERE ordine=?", [ordine3],      
            miodb.webdb.onSuccess, 
            miodb.webdb.onError);
        });
      }

this is my table:
id | content | order

1 |
0 |
0 |

2 |
1 |
1 |

3 |
2 |
2 |

4 |
3 |
3 |

5 |
4 |
4 |

6 |
5 |
5 |

If i delete the first item i wants that all the other item change the order to current order -1, but it doesn’t works, only the last item change the order, ordine2 is set to 0, lunghezza is the length of array.
Who can i fix it?

  • 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-22T18:35:13+00:00Added an answer on May 22, 2026 at 6:35 pm

    You don’t need a loop for this at all. What about the following update statment?

    UPDATE todo SET ordine = ordine - 1
    

    You might need to add an appropriate where clause on that, some thing like “WHERE ordine > ordine2”. I don’t fully understand what it is you’re trying to do so I can’t give you the exact code.

    Also, you really shouldn’t be using string concatenation at all in building your SQL statement, use a ? for every parameter and put them in the array as you did for ordine3, that way you know they’ll be properly escaped.

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

Sidebar

Related Questions

I have this code: chars = #some list try: indx = chars.index(chars) except ValueError:
I have this code: myVariable which I want to change into trace(myVariable: + myVariable);
I have this code, which works fine, but I would like to be able
I have this code. The code below is working in Firefox, but it is
I have this code, that when swapping the order of UsingAs and UsingCast, their
I have this code in one of my @PersistenceCapable classes: @Persistent private Blob data;
I have this code that sends just one attachment by time, how can I
I have this code: http://jsfiddle.net/bUPWS/1/ but #div2 overflows #div1. How to bring the overflowed
I have this code but it doesn't work! public class Trial { public static
I have this code (below) working just fine, however whenever I try to 'wrap'

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.