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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:26:17+00:00 2026-06-17T10:26:17+00:00

I need some support as I’m not so skilled in PHP and MySQL like

  • 0

I need some support as I’m not so skilled in PHP and MySQL like all in this board 🙂
So, thanks in advance.

I’m storing data from an external parsed XML feed with a PHP script.
This script update MySQL database with a CRON Job twice a day.
This is a snipped of such PHP script:

mysql_query("UPDATE my_table SET amount=$jackpot->amount WHERE gameId = '".$jackpot->gameId."'")
or die(mysql_error());

This update a table and a row in my database. This table is structured like this (columns):

gameId | gameName | amount | currency | date

where the “date” column is in DATE format (dd/mm/yyyy hh:mm), CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP.

What I need… I need, yes, to update this table twice a day but I need also to INSERT a new row with the same columns at DATE change (every day, new day->new row).

I’m thinking in something similar, in two words (no coding):

if today --> update rows
elseif date change (another day, so "tomorrow") --> INSERT new row with updated data (collected from the XML feed)

How can I do this?
Have I to check the current data with a MySQL query and then INSERT a new row via PHP?
Or can I skip the query with a bunch of PHP lines?

Sorry, but I’m a little bit confused…
Any help would be really appreciated!

Again, thanks to all!

  • 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-06-17T10:26:18+00:00Added an answer on June 17, 2026 at 10:26 am

    I’d suggest keeping it simple: add a new dupedate field to store ONLY the date of insertion. Put a unique key on it, then it’s a simple matter of:

    INSERT INTO (gameID, gameName, ammount, currency, date, dupedate) VALUES (...)
    ON DUPLICATE KEY UPDATE amount=xxx
    

    If you “insert” a record with the same date as an existing record, you get an update. If it’s a new date (e.g. ‘tomorrow’), you’ll get a new record instead.

    This also has the advantage of not being a racey as your initial “fetch/check/update|insert” version. Such a process leaves open the possibility that some OTHER process may duplicate the logic and snipe away your new record from under you in between the time you fetch the record and when you do the insert/update.

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

Sidebar

Related Questions

I need some clever logging library for a daemon-like C (not C++ ) program
I'm using Jetty with mysql. I need some basic transaction support, and jetty is
Need some help please with this error : TypeError : 'unicode' object does not
Now I'm working on Qt project and I need some MySQL support. MySQL was
Does Twig support ternary (shorthand if-else) operator? I need some conditional logic like: {%if
So i need some support with my Ruby assignment, I'm not from US so
Lucene does not support it out of the box, so I need some help
I need some support regard a MySQL query. I really don't know if possible
Need some help to solve this. I have a gridview and inside the gridview
Need some guidance figuring out what went wrong. I've been using mysql, phpmyadmin for

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.