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 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'm using Zend_Search_Lucene, the PHP port of Java Lucene. I currently have some code
I have some python code that currently performs expensive computation by performing the computation
I have some code that currently checks for minimum and maximum lentgh. I want
I have some PHP AJAX code that is supposed to validate some parameters sent
I have some PHP code (written by someone else) that's parsing a html file
I have a form that takes some user details, and allows them to upload
I have some code that is using the PHP cURL library to upload some
I currently have some action associated with when the user types something in a
I currently have some code which when you press the submit button, a marker
We have some stuff that may be exported into various formats. Currently we have

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.