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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:15:40+00:00 2026-06-02T15:15:40+00:00

PHP and mySQL question I hope you could help me out with. I have

  • 0

PHP and mySQL question I hope you could help me out with. I have an update database option (by clicking a button, it runs the update.php file), now this update.php is responsible for trying to separate my PASSENGER table.

At the moment, I have one massive PASSENGER table, where if there trip with the business happens today (it is a travel booking firm), then they are in the CUSTOMER table, but I want any archived customers (e.g. anyone that travelled from yesterday backwards, to be put into the ARCHIVED_CUSTOMER table.

Now at the moment, I have a small PHP script that is adding to the ARCHIVED_PASSENGER table using the information from the current PASSENGER table, but only where the parameter is the PASSENGER ID.

I am quite comfortable with the DELETE FROM PASSENGER part of the script, but was wondering if anyone knew the code that would allow me to collect and move mass information from the database, where the DATE OF TRAVEL is yesterday onwards etc.. it is done through the activeUntil part of the PASSENGER table.

Very stripped down PHP script, but hope I’ve made myself clear!

   mysql_connect("localhost", "mysql_username", "mysql_password") or die(mysql_error());
    mysql_select_db("mysql_database") or die(mysql_error());

    $query10 = ("SELECT p.surname, p.passNo, p.activeUntil FROM PASSENGER p WHERE passNo = '20120003'");

            $result = mysql_query($query10);  
            while($row = mysql_fetch_array($result))
            {

$surname =  $row['surname'];
$passNo = $row['passNo']; 

mysql_query("INSERT INTO ARCHIVED_PASSENGER (surname, passNo) VALUES ('$surname', '$passNo')  ") 
    or die(mysql_error());  

    mysql_query("DELETE FROM PASSENGER (surname, passNo) VALUES ('$surname', '$passNo')  ") 
    or die(mysql_error());  


        }
  • 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-02T15:15:44+00:00Added an answer on June 2, 2026 at 3:15 pm

    NOW() in MySQL gives the current timestamp. 24 hours ago is DATE_ADD(NOW(),INTERVAL -1 DAY).

    You can compare dates just like numbers: activeUntil < DATE_ADD(NOW(),INTERVAL -1 DAY) selects rows where the activeUntil was anything before 24 hours ago.

    You can combine INSERT and SELECT like so:

    INSERT INTO `archived_passenger` (columns.....) SELECT columns... FROM `passenger` WHERE ...
    

    (You can omit the first set of columns if the names of the columns in achived_passenger exactly match those in passenger, and you can use * instead of the second set of columns if you want to select all columns)

    I think that should be enough infomation to help you do what you’re trying to do. Let me know if you need any additional help.

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

Sidebar

Related Questions

The question is: How to save user input linebreak to database. (jQuery/php/mysql) I have
The only similar question I have found is: Insert php boolean into mysql bit
I have a PHP/mySQL search script that for some reason, after the latest update
Further to my previous question about salted passwords in PHP/MySQL , I have another
Hope you are fine. My question : In MYSQL i have a table with
I have, what I think/hope, is a very simple PHP question. I have made
Newbie question about PostgreSQL. I'm migrating a MySQL/PHP app I've created, hosted on a
PHP/MySQL (CodeIgniter) I would like to add new interest_keywords in the exist database value.
Using PHP / MySQL all encoded up as UTF, we have recently had to
Possible Duplicate: PHP/MYSQL using an array in WHERE clause I have an array with

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.