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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T14:30:01+00:00 2026-05-21T14:30:01+00:00

I am trying to check my database and return any new additions to the

  • 0

I am trying to check my database and return any new additions to the DB.

My client can pass in the ID of the last item it received from the DB. So i think that would be a good starting place.

So is it the case that I set the offset to the ID(theid) i pass in as an argument to the php script and that will only return Database entries newer than that id? Or am i barking up the wrong tree altogether?

Here is what I mean with code

$theid  = isset($_GET['theid']) ? $_GET['theid'] : "";
$type   = isset($_GET['type']) ? $_GET['type'] : "global";
$offset = isset($_GET['offset']) ? $_GET['offset'] : theid;
$count  = isset($_GET['count']) ? $_GET['count'] : "100";
$sort   = isset($_GET['sort']) ? $_GET['sort'] : "id ASC";

// Localize the GET variables
$udid  = isset($_GET['udid']) ? $_GET['udid'] : "";
$name  = isset($_GET['name']) ? $_GET['name']  : "";
$clubname  = isset($_GET['clubname']) ? $_GET['clubname']  : "";

// Protect against sql injections
$type   = mysql_real_escape_string($type);
$offset = mysql_real_escape_string($offset);
$count  = mysql_real_escape_string($count);
$sort   = mysql_real_escape_string($sort);
$udid   = mysql_real_escape_string($udid);
$name   = mysql_real_escape_string($name);
$clubname   = mysql_real_escape_string($clubname);

// Build the sql query
$sql = "SELECT * FROM $table WHERE ";

switch($type) {
    case "global":
        $sql .= "1 ";
        break;
    case "device":
        $sql .= "udid = '$udid' ";
        break;
    case "name":
        $sql .= "name = '$name' ";
        break;
    case "clubname":
        $sql .= "clubname = '$clubname' ";
        break;
}

$sql .= "ORDER BY $sort ";
$sql .= "LIMIT $offset,$count ";

$result = mysql_query($sql,$conn);

if(!$result) {
    die("Error retrieving scores " . mysql_error());
}

Many Thanks,
-Code

  • 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-21T14:30:02+00:00Added an answer on May 21, 2026 at 2:30 pm

    Assuming that the ID is a sequenced number, and newer entries will ALWAYS have a higher ID than the previous, you want the following:

    SELECT * FROM table WHERE id > $id;
    

    Otherwise, you need to add a timestamp to your tables, and run two queries:

    SELECT createdAt FROM table WHERE id = $id;

    Assign that value to $timestamp and then run the following:

    SELECT * FROM table WHERE createdAt > $timestamp
    

    Optionally, you could combine the queries:

    SELECT * FROM table WHERE createdAt > (SELECT createdAt FROM table WHERE id = $id)
    

    Using the offset is a bad idea. If any records prior to your ID are deleted, your results will be inaccurate. For example, lets say the following happens:

    • Insert 100 records (last ID is 100)
    • Delete records 47 and 48
    • Add 1 record ( last ID is 101 )
    • Find records new since id #100

    If you use an offset of 100, you will have no records returned.

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

Sidebar

Related Questions

I am trying to enforce a CHECK Constraint in a ORACLE Database on multiple
I'm trying to create a check on a few columns in my database that
After dynamically creating a client-side table based on SELECT information retrieved from MySql database,
I am trying to create a database from a SQL query I've been sent.
Here's what I'm trying to do. I'm trying to pull data from a database
I am trying to check if certain ID already exists in database. When it
Okay, I'm trying to verify a subscription from a database (which appears to work
im trying to add a new user to my database via a form i
I am trying to implement Google Check out (GCO) on a new server, the
I have a database of last names, first names, addresses, etc. I am trying

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.