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

  • Home
  • SEARCH
  • 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 3444260
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:53:35+00:00 2026-05-18T08:53:35+00:00

We currently have some php code that allows an end user to update records

  • 0

We currently have some php code that allows an end user to update records in our database by filling out a few fields on a form. The database has a field called sequentialNumber, and the user can enter a starting number and ending number, and an update query runs in the background on all records with a sequentialNumber between the starting and ending numbers. This is a pretty quick query.

We’ve been running into some problems lately where people are trying to update records that don’t exist. Now, this isn’t an issue on the database end, but they want to be notified if records don’t exist, and if so, which ones don’t exist.

The only way I can think of to do this is to run a select query in a loop:

for ($i=$startNum; $i<=$endNum; $i++)  {

 //run select query: select sequentialNumber from myTable where sequentialNumber = $startNum;

}

The problem is, our shared host has a timeout limit on scripts, and if the sequentialNumber batch is large enough, the script will time out. Is there a better way of checking for the existence of the records before running the update query?

EDIT:
It just occurred to me that I could do another kind of test: get the number of records they’re trying to update ($endNum – $startNum), and then do a count query:

select count(sequentialNumber) where sequentialNumber between $startNum and $endNum

If the result of the query is not the same as the value of the subtraction, then we know that all the records aren’t there. It wouldn’t be able to tell us WHICH ones aren’t there, but at least we’d know something wasn’t as expected. Is this a valid way to do things?

  • 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-18T08:53:35+00:00Added an answer on May 18, 2026 at 8:53 am

    You could try

    select sequentialNumber from myTable where sequentialNumber between $startNum and $endNum
    

    This will return all known numbers in that range. Then you can use the array_search function to find out if a certain number is known or not. This should be faster than doing a lot of queries to the db.

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

Sidebar

Related Questions

I have a question regarding JavaScript and methods by which its code can be
I have the following code shown below to allow the admin to add a
HI I'm building a php based website and wanted to know if there any
I am fairly new to web programming, I have mainly used java to create
Okay, I'm having some serious issues here. I'm new to this site, and new
I'd like to be able to guess the user's timezone offset and whether or
I'm trying to load profile images (friend images) from Facebook with AS3 but I
Wondering if anyone else has encountered this problem when utilizing the new ability to
I am working on a site which people already know the URL of. Naturally,

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.